Commit 5be6a841 by Qiang Xue

Cleaned up doc. [skip ci]

parent 033d66de
...@@ -301,17 +301,17 @@ yii fixture User ...@@ -301,17 +301,17 @@ yii fixture User
// load several fixtures // load several fixtures
yii fixture User UserProfile yii fixture User UserProfile
//load fixture, but dont clean storage before load and just append to already existed data //load fixture, but don't clean storage before load and just append to already existed data
yii fixture User --append yii fixture User --append
// load all fixtures // load all fixtures
yii fixture/load all yii fixture/load *
// same as above // same as above
yii fixture all yii fixture *
// load all fixtures except ones // load all fixtures except ones
yii fixture all -DoNotLoadThisOne yii fixture * -DoNotLoadThisOne
// load fixtures, but search them in different namespace. By default namespace is: tests\unit\fixtures. // load fixtures, but search them in different namespace. By default namespace is: tests\unit\fixtures.
yii fixture User --namespace='alias\my\custom\namespace' yii fixture User --namespace='alias\my\custom\namespace'
......
...@@ -15,7 +15,7 @@ use yii\helpers\FileHelper; ...@@ -15,7 +15,7 @@ use yii\helpers\FileHelper;
use yii\test\FixtureTrait; use yii\test\FixtureTrait;
/** /**
* Manages loading and unloading fixtures. * Manages fixture data loading and unloading.
* *
* ~~~ * ~~~
* #load fixtures from UsersFixture class with default namespace "tests\unit\fixtures" * #load fixtures from UsersFixture class with default namespace "tests\unit\fixtures"
...@@ -24,8 +24,11 @@ use yii\test\FixtureTrait; ...@@ -24,8 +24,11 @@ use yii\test\FixtureTrait;
* #also a short version of this command (generate action is default) * #also a short version of this command (generate action is default)
* yii fixture User * yii fixture User
* *
* #load all fixtures
* yii fixture *
*
* #load all fixtures except User * #load all fixtures except User
* yii fixture all -User * yii fixture * -User
* *
* #append fixtures to already loaded * #append fixtures to already loaded
* yii fixture User --append * yii fixture User --append
...@@ -34,7 +37,7 @@ use yii\test\FixtureTrait; ...@@ -34,7 +37,7 @@ use yii\test\FixtureTrait;
* yii fixture/load User --namespace=alias\my\custom\namespace\goes\here * yii fixture/load User --namespace=alias\my\custom\namespace\goes\here
* ~~~ * ~~~
* *
* Same examples are true for unloading fixtures, except append option. * The `unload` sub-command can be used similarly to unload fixtures.
* *
* @author Mark Jebri <mark.github@yandex.ru> * @author Mark Jebri <mark.github@yandex.ru>
* @since 2.0 * @since 2.0
...@@ -44,11 +47,6 @@ class FixtureController extends Controller ...@@ -44,11 +47,6 @@ class FixtureController extends Controller
use FixtureTrait; use FixtureTrait;
/** /**
* type of fixture apply to database
*/
const APPLY_ALL = '*';
/**
* @var string controller default action ID. * @var string controller default action ID.
*/ */
public $defaultAction = 'load'; public $defaultAction = 'load';
...@@ -57,8 +55,8 @@ class FixtureController extends Controller ...@@ -57,8 +55,8 @@ class FixtureController extends Controller
*/ */
public $namespace = 'tests\unit\fixtures'; public $namespace = 'tests\unit\fixtures';
/** /**
* @var bool whether to clean fixtures storage before apply or load them * @var bool whether to append new fixture data to the existing ones.
* in the end of already existed fixtures * Defaults to false, meaning if there is any existing fixture data, it will be removed.
*/ */
public $append = false; public $append = false;
/** /**
...@@ -81,15 +79,26 @@ class FixtureController extends Controller ...@@ -81,15 +79,26 @@ class FixtureController extends Controller
} }
/** /**
* Loads given fixture. You can load several fixtures specifying * Loads the specified fixture data.
* their names separated with space, like: User UserProfile MyCustom. * For example,
* Note that if you are loading fixtures to storage, for example: database or nosql, *
* storage will not be cleared, data will be appended to already existed. If you want to append * ~~~
* fixtures data to already existed one use "--append" option of this command. * # load the fixture data specified by User and UserProfile.
* If you dont want to unload particular fixture, then specify it with "-" prefix. * # any existing fixture data will be removed first
* @param array $fixtures * yii fixture/load User UserProfile
* @param array $except *
* @throws \yii\console\Exception * # load the fixture data specified by User and UserProfile.
* # the new fixture data will be appended to the existing one
* yii fixture/load --append User UserProfile
*
* # load all available fixtures found under 'tests\unit\fixtures'
* yii fixture/load *
*
* # load all fixtures except User and UserProfile
* yii fixture/load * -User -UserProfile
* ~~~
*
* @throws Exception if the specified fixture does not exist.
*/ */
public function actionLoad() public function actionLoad()
{ {
...@@ -147,10 +156,21 @@ class FixtureController extends Controller ...@@ -147,10 +156,21 @@ class FixtureController extends Controller
} }
/** /**
* Unloads given fixtures. You can unload several fixtures specifying * Unloads the specified fixtures.
* their names separated with space, like: User UserProfile MyCustom. * For example,
* If you dont want to unload particular fixture, then specify it with "-" prefix. *
* @throws \yii\console\Exception in case no fixtures are found. * ~~~
* # unload the fixture data specified by User and UserProfile.
* yii fixture/unload User UserProfile
*
* # unload all fixtures found under 'tests\unit\fixtures'
* yii fixture/unload *
*
* # unload all fixtures except User and UserProfile
* yii fixture/unload * -User -UserProfile
* ~~~
*
* @throws Exception if the specified fixture does not exist.
*/ */
public function actionUnload() public function actionUnload()
{ {
...@@ -352,7 +372,7 @@ class FixtureController extends Controller ...@@ -352,7 +372,7 @@ class FixtureController extends Controller
*/ */
public function needToApplyAll($fixture) public function needToApplyAll($fixture)
{ {
return $fixture == self::APPLY_ALL; return $fixture == '*';
} }
/** /**
...@@ -410,7 +430,7 @@ class FixtureController extends Controller ...@@ -410,7 +430,7 @@ class FixtureController extends Controller
} }
/** /**
* Filteres fixtures by splitting them in two categories: one that should be applied and not. * Filters fixtures by splitting them in two categories: one that should be applied and not.
* If fixture is prefixed with "-", for example "-User", that means that fixture should not be loaded, * If fixture is prefixed with "-", for example "-User", that means that fixture should not be loaded,
* if it is not prefixed it is considered as one to be loaded. Returs array: * if it is not prefixed it is considered as one to be loaded. Returs array:
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment