PHP 트레잇 yii\test\FixtureTrait

By using FixtureTrait, a test class will be able to specify which fixtures to load by overriding the FixtureTrait::fixtures method. It can then load and unload the fixtures using FixtureTrait::loadFixtures and FixtureTrait::unloadFixtures. Once a fixture is loaded, it can be accessed like an object property, thanks to the PHP __get() magic method. Also, if the fixture is an instance of ActiveFixture, you will be able to access AR models through the syntax $this->fixtureName('model name').
부터: 2.0
저자: Qiang Xue ([email protected])
파일 보기 프로젝트 열기: yiisoft/yii2

공개 메소드들

메소드 설명
fixtures ( ) : array Declares the fixtures that are needed by the current test case.
getFixture ( string $name ) : Fixture Returns the named fixture.
getFixtures ( ) : Fixture[] Returns the fixture objects as specified in FixtureTrait::globalFixtures and FixtureTrait::fixtures.
globalFixtures ( ) : array Declares the fixtures shared required by different test cases.
loadFixtures ( Fixture[] $fixtures = null ) Loads the specified fixtures.
unloadFixtures ( Fixture[] $fixtures = null ) Unloads the specified fixtures.

보호된 메소드들

메소드 설명
createFixtures ( array $fixtures ) : Fixture[] Creates the specified fixture instances.

메소드 상세

createFixtures() 보호된 메소드

All dependent fixtures will also be created.
protected createFixtures ( array $fixtures ) : Fixture[]
$fixtures array the fixtures to be created. You may provide fixture names or fixture configurations. If this parameter is not provided, the fixtures specified in [[globalFixtures()]] and [[fixtures()]] will be created.
리턴 Fixture[] the created fixture instances

fixtures() 공개 메소드

The return value of this method must be an array of fixture configurations. For example, php [ anonymous fixture PostFixture::className(), "users" fixture 'users' => UserFixture::className(), "cache" fixture with configuration 'cache' => [ 'class' => CacheFixture::className(), 'host' => 'xxx', ], ] Note that the actual fixtures used for a test case will include both FixtureTrait::globalFixtures and FixtureTrait::fixtures.
public fixtures ( ) : array
리턴 array the fixtures needed by the current test case

getFixture() 공개 메소드

Returns the named fixture.
public getFixture ( string $name ) : Fixture
$name string the fixture name. This can be either the fixture alias name, or the class name if the alias is not used.
리턴 Fixture the fixture object, or null if the named fixture does not exist.

getFixtures() 공개 메소드

Returns the fixture objects as specified in FixtureTrait::globalFixtures and FixtureTrait::fixtures.
public getFixtures ( ) : Fixture[]
리턴 Fixture[] the loaded fixtures for the current test case

globalFixtures() 공개 메소드

The return value should be similar to that of FixtureTrait::fixtures. You should usually override this method in a base class.
또한 보기: fixtures()
public globalFixtures ( ) : array
리턴 array the fixtures shared and required by different test cases.

loadFixtures() 공개 메소드

This method will call [[Fixture::load()]] for every fixture object.
public loadFixtures ( Fixture[] $fixtures = null )
$fixtures Fixture[] the fixtures to be loaded. If this parameter is not specified, the return value of [[getFixtures()]] will be used.

unloadFixtures() 공개 메소드

This method will call [[Fixture::unload()]] for every fixture object.
public unloadFixtures ( Fixture[] $fixtures = null )
$fixtures Fixture[] the fixtures to be loaded. If this parameter is not specified, the return value of [[getFixtures()]] will be used.