Commit b133c6c3 by Mark

docs improved

parent 932fc224
......@@ -39,6 +39,7 @@ return [
If we are using fixture that loads data into database then these rows will be applied to `users` table. If we are using nosql fixtures, for example `mongodb`
fixture, then this data will be applied to `users` mongodb collection. In order to learn about implementing various loading strategies and more, refer to official [documentation](https://github.com/yiisoft/yii2/blob/master/docs/guide/test-fixture.md).
Above fixture example was auto-generated by `yii2-faker` extension, read more about it in these [section](#auto-generating-fixtures).
Fixture classes name should not be plural.
Loading fixtures
----------------
......@@ -57,13 +58,13 @@ Below are correct formats of this command:
```
// apply `users` fixture
yii fixture/apply Users
yii fixture/apply User
// same as above, because default action of "fixture" command is "apply"
yii fixture Users
yii fixture User
// apply several fixtures. Note that there should not be any whitespace between ",", it should be one string.
yii fixture Users,UsersProfiles
yii fixture User,UserProfile
// apply all fixtures
yii fixture/apply all
......@@ -71,17 +72,11 @@ yii fixture/apply all
// same as above
yii fixture all
// apply Users fixture, but fixture will be taken from different path.
yii fixture Users --fixturePath='@app/my/custom/path/to/fixtures'
// apply fixtures, but for other database connection.
yii fixtures Users --db='customDbConnectionId'
yii fixtures User --db='customDbConnectionId'
// apply fixtures, but search them in different namespace. By default namespace is: tests\unit\fixtures.
yii fixtures Users --namespace='my/custom/namespace'
// apply fixtures without namespace under fixturesPath
yii fixtures all --namespace=''
yii fixtures User --namespace='alias\my\custom\namespace'
```
Unloading fixtures
......@@ -91,16 +86,16 @@ To unload fixture, run the following command:
```
// unload Users fixture, by default it will clear fixture storage (for example "users" table, or "users" collection if this is mongodb fixture).
yii fixture/clear Users
yii fixture/clear User
// Unload several fixtures. Note that there should not be any whitespace between ",", it should be one string.
yii fixture/clear Users,UsersProfiles
yii fixture/clear User,UserProfile
// unload all fixtures
yii fixture/clear all
```
Same command options like: `fixturesPath`, `db`, `namespace` also can be applied to this command.
Same command options like: `db`, `namespace` also can be applied to this command.
Configure Command Globally
--------------------------
......@@ -112,8 +107,8 @@ different migration path as follows:
'controllerMap' => [
'fixture' => [
'class' => 'yii\console\FixtureController',
'fixturePath' => '@app/my/custom/path/to/fixtures',
'db' => 'customDbConnectionId',
'namespace' => 'myalias\some\custom\namespace',
],
]
```
......
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