Trait yii\test\FileFixtureTrait

Implemented byyii\test\ActiveFixture, yii\test\ArrayFixture, yii\test\BaseActiveFixture
可用自版本2.0.14
源代码 https://github.com/yiisoft/yii2/blob/master/framework/test/FileFixtureTrait.php

FileFixtureTrait provides functionalities for loading data fixture from file.

公共属性

隐藏继承的属性

属性类型描述定义在
$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

受保护的方法

隐藏继承的方法

方法描述定义在
loadData() Returns the fixture data. yii\test\FileFixtureTrait

属性详情

$dataDirectory public 属性

The directory path or path alias that contains the fixture data

public string $dataDirectory null
$dataFile public 属性

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.

public string|boolean $dataFile null

方法详情

loadData() protected 方法

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.