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

Property Description
currentTest \Codeception\TestInterface
instance self – The current instance

# currentTest

Type
\Codeception\TestInterface

View source

# instance

Type
self

The current instance

View source

# Protected Properties

Property Description
addedConfig array – Application config file must be set.
requiredEvents array – For expecting events code
triggeredEvents array – 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

Method Description
__construct() Craft constructor.
_afterSuite()
_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)

# _afterSuite()

View source

Throws

# _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

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