PHP Class yii\mongodb\ActiveFixture

Either [[modelClass]] or [[collectionName]] 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::resetCollection to remove any existing data in the collection. 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()]].
Since: 2.0
Author: Paul Klimov ([email protected])
Inheritance: extends yii\test\BaseActiveFixture
Datei anzeigen Open project: yiisoft/yii2-mongodb

Public Properties

Property Type Description
$collectionName the collection name that this fixture is about. If this property is not set, the collection name will be determined via [[modelClass]].
$db the DB connection object or the application component ID of the DB connection.

Public Methods

Method Description
init ( )
load ( ) Loads the fixture data.

Protected Methods

Method Description
getCollection ( ) : Collection Returns collection used by this fixture.
getCollectionName ( ) : array | string Returns collection name used by this fixture.
getData ( ) : array Returns the fixture data.
resetCollection ( ) Removes all existing data from the specified collection and resets sequence number if any.

Method Details

getCollection() protected method

Returns collection used by this fixture.
protected getCollection ( ) : Collection
return Collection related collection.

getCollectionName() protected method

Returns collection name used by this fixture.
protected getCollectionName ( ) : array | string
return array | string related collection name

getData() protected method

This method is called by [[loadData()]] to get the needed fixture data. 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 collection. If the data file does not exist, an empty array will be returned.
protected getData ( ) : array
return array the data rows to be inserted into the collection.

init() public method

public init ( )

load() public method

The default implementation will first reset the MongoDB collection and then populate it with the data returned by ActiveFixture::getData.
public load ( )

resetCollection() protected method

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

Property Details

$collectionName public_oe property

the collection name that this fixture is about. If this property is not set, the collection name will be determined via [[modelClass]].
See also: Connection::getCollection()
public $collectionName

$db public_oe property

the DB connection object or the application component ID of the DB connection.
public $db