Craft

Type
Class
Namespace
craft\test
Inherits
craft\test\Craft » Codeception\Module\Yii2
Since
3.2.0

Craft module for codeception

View source

Public Properties

PropertyDescription
currentTest\Codeception\TestInterface
testConfigarray – A static version of the testing config.

currentTest

Type
\Codeception\TestInterface

View source

testConfig

Type
array

A static version of the testing config.

Will be set very early on in the testing processes so it can be used in configuration files such as general.php and test.php. This variable is equivalant to calling $this->_getConfig(); but is available for public access.

View source

Protected Properties

PropertyDescription
addedConfigarray – Application config file must be set.
requiredEventsarray – For expecting events code
triggeredEventsarray – For expecting events code

addedConfig

Type
array

Application config file must be set.

View source

requiredEvents

Type
array

For expecting events code

View source

triggeredEvents

Type
array

For expecting events code

View source

Public Methods

MethodDescription
__construct()Craft constructor.
_before()
_initialize()
assertElementsExist()
assertEqualDates()
assertPushedToQueue()
assertTestFails()
createDbConfig()Creates a DB config according to the loaded .env variables.
createEventItems()
expectEvent()Ensure that an event is triggered by the $callback() function.
getCodeceptionName()
getFieldLayoutByFieldHandle()
installPlugin()
mockCraftMethods()
mockMethods()
normalizePathSeparators()
resetProjectConfig()Reset's the project config.
runQueue()An easy way of handling the testing of queue jobs.
saveElement()
setupDb()

__construct()

Craft constructor. We need to merge the config settings here as this is the earliest point in the instance's existence. Doing it in _initialize() won't work as the config variables have already been added.

View source

Arguments

  • $moduleContainer (\Codeception\Lib\ModuleContainer)
  • $config (null)

_before()

View source

Arguments

  • $test (\Codeception\TestInterface)

Throws

_initialize()

View source

assertElementsExist()

View source

Arguments

  • $elementType (string)
  • $searchProperties (array)
  • $amount (integer)
  • $searchAll (boolean) – - Wether anyStatus() and trashed(null) should be applied

Returns

array

assertEqualDates()

View source

Arguments

  • $test (\Codeception\TestInterface)
  • $dateOne (string)
  • $dateTwo (string)
  • $secondsDelta (float)

Throws

assertPushedToQueue()

View source

Arguments

assertTestFails()

View source

Arguments

createDbConfig()

Creates a DB config according to the loaded .env variables.

View source

Returns

craft\config\DbConfig

createEventItems()

View source

Arguments

Returns

array

expectEvent()

Ensure that an event is triggered by the $callback() function.

View source

Arguments

getCodeceptionName()

View source

Returns

string

getFieldLayoutByFieldHandle()

View source

Arguments

Returns

craft\models\FieldLayout, null

installPlugin()

View source

Arguments

Throws

mockCraftMethods()

View source

Arguments

Throws

mockMethods()

View source

Arguments

Throws

normalizePathSeparators()

View source

Arguments

  • $path

Returns

string, boolean

resetProjectConfig()

Since
3.3.10

Reset's the project config.

View source

Arguments

  • $force (boolean) – Whether to force the reset. If set to true the reset key of the projectConfig configuration will be ignored and the project config will be reset regardless.

Returns

boolean

runQueue()

An easy way of handling the testing of queue jobs.

View source

Arguments

Throws

saveElement()

View source

Arguments

Returns

boolean

Throws

setupDb()

View source

Throws

Protected Methods

addModule()

View source

Arguments

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

Throws

mockModulesAndPlugins()

View source

Arguments

  • $test (\Codeception\PHPUnit\TestCase)

Throws

recreateClient()

View source

validateEventValue()

View source

Arguments