yii\test\FileFixtureTrait - Yii2 类参考手册

Trait yii\test\FileFixtureTrait

Implemented byyii\elasticsearch\ActiveFixture, yii\mongodb\ActiveFixture, yii\test\ActiveFixture, yii\test\ArrayFixture, yii\test\BaseActiveFixture
Available since version2.0.14

FileFixtureTrait provides functionalities for loading data fixture from file.

Public Properties

隐藏继承的属性 Hide inherited 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 \yii\test\getData(). yii\test\FileFixtureTrait

Protected Methods

隐藏继承的方法 Hide inherited methods

方法 Method简介 Description定义在 Defined By
loadData() Returns the fixture data. yii\test\FileFixtureTrait

属性详情 Property Details

$dataDirectory public property

The directory path or path alias that contains the fixture data

public string $dataDirectory null
$dataFile public property

The file path or path alias of the data file that contains the fixture data to be returned by \yii\test\getData(). You can set this property to be false to prevent loading any data.

public string|boolean $dataFile null

方法详情 Method Details

loadData() protected method

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 \yii\test\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.