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 (opens new window)

# Public Methods

Method Description
appClass()
appType() Determine the app type (console or web).
cleanseDb()
configureCraft()
createConfigService()
createTestCraftObjectConfig()
getCraftServiceMap()
getMock()
getMockApp()
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 (opens new window)

Arguments

Returns

string (opens new window)

# appType()

Determine the app type (console or web).

View source (opens new window)

Returns

string (opens new window)

# cleanseDb()

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Throws

# configureCraft()

View source (opens new window)

Returns

boolean (opens new window)

# createConfigService()

View source (opens new window)

Returns

craft\services\Config

# createTestCraftObjectConfig()

View source (opens new window)

Returns

array (opens new window)

# getCraftServiceMap()

View source (opens new window)

Returns

array (opens new window)

# getMock()

View source (opens new window)

Arguments

Returns

\PHPUnit\Framework\MockObject\MockObject

# getMockApp()

View source (opens new window)

Arguments

Returns

\PHPUnit\Framework\MockObject\MockObject

# getSeedProjectConfigData()

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

View source (opens new window)

Returns

array (opens new window) – The project config in either yaml or as an array.

# removeProjectConfigFolders()

View source (opens new window)

Arguments

  • $path

Throws

# setupCraftDb()

View source (opens new window)

Arguments

Throws

# setupProjectConfig()

View source (opens new window)

Arguments

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

Throws

# tearDownCraft()

Taken from the Yii2 Module $i->_after

View source (opens new window)

# useProjectConfig()

Whether project config should be used in tests.

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

View source (opens new window)

Returns

array (opens new window), false (opens new window)

# validateAndApplyMigration()

View source (opens new window)

Arguments

Returns

boolean (opens new window)

Throws

# warmCraft()

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

View source (opens new window)

Returns

mixed

Throws

# Constants

Constant Description
SITE_URL
USERNAME