Trait yii\test\FileFixtureTrait
Implemented by | yii\elasticsearch\ActiveFixture, yii\mongodb\ActiveFixture, yii\sphinx\ActiveFixture, yii\test\ActiveFixture, yii\test\ArrayFixture, yii\test\BaseActiveFixture |
---|---|
Available since version | 2.0.14 |
Source Code | https://github.com/yiisoft/yii2/blob/master/framework/test/FileFixtureTrait.php |
FileFixtureTrait provides functionalities for loading data fixture from file.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$dataDirectory | string | The directory path or path alias that contains the fixture data | yii\test\FileFixtureTrait |
$dataFile | string|boolean | The file path or path alias of the data file that contains the fixture data to be returned by getData(). | yii\test\FileFixtureTrait |
Protected Methods
Method | Description | Defined By |
---|---|---|
loadData() | Returns the fixture data. | yii\test\FileFixtureTrait |
Property Details
The directory path or path alias that contains the fixture data
The file path or path alias of the data file that contains the fixture data to be returned by getData(). You can set this property to be false to prevent loading any data.
Method Details
Returns the fixture data.
The default implementation will try to return the fixture data by including the external file specified by $dataFile. The file should return the data array that will be stored in data after inserting into the database.
protected array loadData ( $file, $throwException = true ) | ||
$file | string | The data file path |
$throwException | boolean | Whether to throw exception if fixture data file does not exist. |
return | array | The data to be put into the database |
---|---|---|
throws | yii\base\InvalidConfigException | if the specified data file does not exist. |