TestSetup

Type
Class
Namespace
craft\test
Inherits
craft\test\TestSetup
Since
3.2

Class TestSetup.

TestSetup performs various setup tasks required for craft\test\Craft. It is not intended for use within public tests. Use the various features of craft\test\Craft instead.

View source

# Public Methods

Method Description
appClass()
appType() Determine the app type. If the parent is craft\test\console\ConsoleTest.
cleanseDb()
configureCraft()
createConfigService()
createTestCraftObjectConfig()
getCraftServiceMap()
getMock()
getMockApp()
getSeedProjectConfigData() Returns the data from the project.yml file specified in the codeception.yml file.
setupCraftDb()
setupProjectConfig()
tearDownCraft() Taken from the Yii2 Module $i->_after
useProjectConfig() Whether project config should be used in tests.
validateAndApplyMigration()
warmCraft() Creates a craft object to play with. Ensures the Craft::$app service locator is working.

# appClass()

View source

Arguments

Returns

string

# appType()

Determine the app type. If the parent is craft\test\console\ConsoleTest.

Its a console test. Else, web.

View source

Returns

string

# cleanseDb()

View source

Arguments

Returns

boolean

Throws

# configureCraft()

View source

Returns

boolean

# createConfigService()

View source

Returns

craft\services\Config

# createTestCraftObjectConfig()

View source

Returns

array

# getCraftServiceMap()

View source

Returns

array

# getMock()

View source

Arguments

  • $test (\Codeception\PHPUnit\TestCase)
  • $class (string)

Returns

\PHPUnit\Framework\MockObject\MockObject

# getMockApp()

View source

Arguments

  • $test (\Codeception\PHPUnit\TestCase)
  • $serviceMap (array)
  • $appClass (string)

Returns

\PHPUnit\Framework\MockObject\MockObject

# getSeedProjectConfigData()

Returns the data from the project.yml file specified in the codeception.yml file.

View source

Arguments

  • $asYaml (boolean) – Whether the raw yaml data should be returned. If set to false the parsed array data will be returned.

Returns

array, string – The project config in either yaml or as an array.

# setupCraftDb()

View source

Arguments

Throws

# setupProjectConfig()

View source

Arguments

  • $projectConfigFile (string) – - Whether to override the file specified in codeception.yml with a custom file.

Throws

# tearDownCraft()

Taken from the Yii2 Module $i->_after

View source

# useProjectConfig()

Whether project config should be used in tests.

Returns the projectConfig configuration array if yes - false if not.

View source

Returns

array, false

# validateAndApplyMigration()

View source

Arguments

Returns

boolean

Throws

# warmCraft()

Creates a craft object to play with. Ensures the Craft::$app service locator is working.

View source

Returns

mixed

Throws