Commit 19d45b9a by Mark

fixed command and docs

parent 6dd9477a
......@@ -6,7 +6,7 @@ different cases. With this data using your tests becoming more efficient and use
Yii supports fixtures via the `yii fixture` command line tool. This tool supports:
* Loading new fixtures to different storages like: database, nosql, etc;
* Loading fixtures to different storages such as: database, nosql, etc;
* Unloading fixtures in different ways (usually it is clearing storage);
* Auto-generating fixtures and populating it with random data.
......@@ -36,14 +36,14 @@ return [
],
];
```
If we are using fixture that loads data to database then this 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. You can implement different loading strategies and other needed things, for that refer to official [documentation](https://github.com/yiisoft/yii2/blob/master/docs/guide/test-fixture.md).
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).
Loading fixtures
----------------
Fixtures classes should be suffixed by `Fixture` class. By default fixtures will be searched under `tests\unit\fixtures` namespace, you can
Fixture classes should be suffixed by `Fixture` class. By default fixtures will be searched under `tests\unit\fixtures` namespace, you can
change this behavior with config or command options.
To apply fixture, run the following command:
......
......@@ -16,7 +16,7 @@ use yii\test\FixtureTrait;
use yii\helpers\Inflector;
/**
* This command manages fixtures load.
* This command manages loading and unloading fixtures.
* You can specify different options of this command to point fixture manager
* to the specific tables of the different database connections.
*
......@@ -131,12 +131,12 @@ class FixtureController extends Controller
if (!$this->confirmApply($foundFixtures, $except)) {
return;
}
}
$fixtures = $this->getFixturesConfigs(array_diff($foundFixtures, $except));
$fixtures = $this->getFixturesConfig(array_diff($foundFixtures, $except));
if (!$fixtures) {
throw new Exception("No fixtures were found in namespace: \"" . $this->namespace . "\".");
throw new Exception('No fixtures were found in namespace: "' . $this->namespace . '"'.'');
}
$transaction = Yii::$app->db->beginTransaction();
......@@ -183,10 +183,10 @@ class FixtureController extends Controller
return;
}
$fixtures = $this->getFixturesConfigs(array_diff($foundFixtures, $except));
$fixtures = $this->getFixturesConfig(array_diff($foundFixtures, $except));
if (!$fixtures) {
throw new Exception("No fixtures were found in namespace: \"" . $this->namespace . "\".");
throw new Exception('No fixtures were found in namespace: ' . $this->namespace . '".');
}
$transaction = Yii::$app->db->beginTransaction();
......@@ -363,7 +363,7 @@ class FixtureController extends Controller
* @param array $fixtures fixtures to configure
* @return array
*/
private function getFixturesConfigs($fixtures)
private function getFixturesConfig($fixtures)
{
$config = [];
......
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