PHP Class yii\test\ActiveFixture

Either [[modelClass]] or [[tableName]] must be set. You should also provide fixture data in the file specified by [[dataFile]] or overriding ActiveFixture::getData if you want to use code to generate the fixture data. When the fixture is being loaded, it will first call ActiveFixture::resetTable to remove any existing data in the table. It will then populate the table with the data returned by ActiveFixture::getData. After the fixture is loaded, you can access the loaded data via the [[data]] property. If you set [[modelClass]], you will also be able to retrieve an instance of [[modelClass]] with the populated data via [[getModel()]]. For more details and usage information on ActiveFixture, see the guide article on fixtures.
Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends BaseActiveFixture
Afficher le fichier Open project: yiisoft/yii2 Class Usage Examples

Méthodes publiques

Свойство Type Description
$dataFile the file path or path alias of the data file that contains the fixture data to be returned by ActiveFixture::getData. If this is not set, it will default to FixturePath/data/TableName.php, where FixturePath stands for the directory containing this fixture class, and TableName stands for the name of the table associated with this fixture. You can set this property to be false to prevent loading any data.
$tableName the name of the database table that this fixture is about. If this property is not set, the table name will be determined via [[modelClass]].

Méthodes publiques

Méthode Description
getTableSchema ( ) : yii\db\TableSchema
init ( )
load ( ) Loads the fixture.

Méthodes protégées

Méthode Description
getData ( ) : array Returns the fixture data.
resetTable ( ) Removes all existing data from the specified table and resets sequence number to 1 (if any).

Method Details

getData() protected méthode

The default implementation will try to return the fixture data by including the external file specified by [[dataFile]]. The file should return an array of data rows (column name => column value), each corresponding to a row in the table. If the data file does not exist, an empty array will be returned.
protected getData ( ) : array
Résultat array the data rows to be inserted into the database table.

getTableSchema() public méthode

public getTableSchema ( ) : yii\db\TableSchema
Résultat yii\db\TableSchema the schema information of the database table associated with this fixture.

init() public méthode

public init ( )

load() public méthode

The default implementation will first clean up the table by calling ActiveFixture::resetTable. It will then populate the table with the data returned by ActiveFixture::getData. If you override this method, you should consider calling the parent implementation so that the data returned by ActiveFixture::getData can be populated into the table.
public load ( )

resetTable() protected méthode

This method is called before populating fixture data into the table associated with this fixture.
protected resetTable ( )

Property Details

$dataFile public_oe property

the file path or path alias of the data file that contains the fixture data to be returned by ActiveFixture::getData. If this is not set, it will default to FixturePath/data/TableName.php, where FixturePath stands for the directory containing this fixture class, and TableName stands for the name of the table associated with this fixture. You can set this property to be false to prevent loading any data.
public $dataFile

$tableName public_oe property

the name of the database table that this fixture is about. If this property is not set, the table name will be determined via [[modelClass]].
See also: modelClass
public $tableName