PHP Class yii\console\controllers\FixtureController

#load fixtures from UsersFixture class with default namespace "tests\unit\fixtures" yii fixture/load User #also a short version of this command (generate action is default) yii fixture User #load all fixtures yii fixture "*" #load all fixtures except User yii fixture "*, -User" #load fixtures with different namespace. yii fixture/load User --namespace=alias\my\custom\namespace\goes\here The unload sub-command can be used similarly to unload fixtures.
Since: 2.0
Author: Mark Jebri ([email protected])
Inheritance: extends yii\console\Controller, use trait yii\test\FixtureTrait
Mostra file Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$defaultAction controller default action ID.
$globalFixtures global fixtures that should be applied when loading and unloading. By default it is set to InitDbFixture that disables and enables integrity check, so your data can be safely loaded.
$namespace default namespace to search fixtures in

Public Methods

Method Description
actionLoad ( array $fixturesInput = [] ) : integer Loads the specified fixture data.
actionUnload ( array $fixturesInput = [] ) : integer Unloads the specified fixtures.
needToApplyAll ( string $fixture ) : boolean Checks if needed to apply all fixtures.
notifyNothingToLoad ( array $foundFixtures, array $except ) Notifies user that there are no fixtures to load according input conditions
notifyNothingToUnload ( array $foundFixtures, array $except ) Notifies user that there are no fixtures to unload according input conditions
optionAliases ( )
options ( $actionID )

Private Methods

Method Description
confirmLoad ( array $fixtures, array $except ) : boolean Prompts user with confirmation if fixtures should be loaded.
confirmUnload ( array $fixtures, array $except ) : boolean Prompts user with confirmation for fixtures that should be unloaded.
filterFixtures ( array $fixtures ) : array Filters fixtures by splitting them in two categories: one that should be applied and not.
findFixtures ( array $fixtures = [] ) : array Finds fixtures to be loaded, for example "User", if no fixtures were specified then all of them will be searching by suffix "Fixture.php".
getFixturePath ( ) : string Returns fixture path that determined on fixtures namespace.
getFixturesConfig ( array $fixtures ) : array Returns valid fixtures config that can be used to load them.
notifyLoaded ( array $fixtures ) Notifies user that fixtures were successfully loaded.
notifyNotFound ( array $fixtures ) Notifies user that fixtures were not found under fixtures path.
notifyUnloaded ( array $fixtures ) Notifies user that fixtures were successfully unloaded.
outputList ( array $data ) Outputs data to the console as a list.

Method Details

actionLoad() public method

For example, # load the fixture data specified by User and UserProfile. # any existing fixture data will be removed first yii fixture/load "User, UserProfile" # load all available fixtures found under 'tests\unit\fixtures' yii fixture/load "*" # load all fixtures except User and UserProfile yii fixture/load "*, -User, -UserProfile"
public actionLoad ( array $fixturesInput = [] ) : integer
$fixturesInput array
return integer return code

actionUnload() public method

For example, # unload the fixture data specified by User and UserProfile. yii fixture/unload "User, UserProfile" # unload all fixtures found under 'tests\unit\fixtures' yii fixture/unload "*" # unload all fixtures except User and UserProfile yii fixture/unload "*, -User, -UserProfile"
public actionUnload ( array $fixturesInput = [] ) : integer
$fixturesInput array
return integer return code

needToApplyAll() public method

Checks if needed to apply all fixtures.
public needToApplyAll ( string $fixture ) : boolean
$fixture string
return boolean

notifyNothingToLoad() public method

Notifies user that there are no fixtures to load according input conditions
public notifyNothingToLoad ( array $foundFixtures, array $except )
$foundFixtures array array of found fixtures
$except array array of names of fixtures that should not be loaded

notifyNothingToUnload() public method

Notifies user that there are no fixtures to unload according input conditions
public notifyNothingToUnload ( array $foundFixtures, array $except )
$foundFixtures array array of found fixtures
$except array array of names of fixtures that should not be loaded

optionAliases() public method

Since: 2.0.8
public optionAliases ( )

options() public method

public options ( $actionID )

Property Details

$defaultAction public_oe property

controller default action ID.
public $defaultAction

$globalFixtures public_oe property

global fixtures that should be applied when loading and unloading. By default it is set to InitDbFixture that disables and enables integrity check, so your data can be safely loaded.
public $globalFixtures

$namespace public_oe property

default namespace to search fixtures in
public $namespace