Skip to content

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 ​

MethodDescription
appClass()
appType()Determine the app type (console or web).
cleanseDb()
configureCraft()
createConfigService()
createTestCraftObjectConfig()
getCraftServiceMap()
getMock()
getMockModule()
getSeedProjectConfigData()Returns the data from the project.yml file specified in the codeception.yml file.
removeProjectConfigFolders()
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 (console or 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 ​

\craft\test\T, \PHPUnit\Framework\MockObject\MockObject

getMockModule() ​

View source

Arguments ​

  • $test (\Codeception\PHPUnit\TestCase)
  • $serviceMap (array)
  • $moduleClass (string, null)

Returns ​

\craft\test\T

getSeedProjectConfigData() ​

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

View source

Returns ​

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

removeProjectConfigFolders() ​

View source

Arguments ​

Throws ​

setupCraftDb() ​

View source

Arguments ​

Throws ​

setupProjectConfig() ​

View source

Arguments ​

  • $projectConfigFolder (string, null) – - Whether to override the folder specified in codeception.yml with a custom folder.

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 ​

Constants ​

ConstantDescription
SITE_URL
USERNAME