Skip to content

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
instanceself – The current instance

currentTest

Type
\Codeception\TestInterface
Default value
null

View source

instance

Type
self
Default value
null

The current instance

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
Default value
[ 'migrations' => [], 'plugins' => [], 'dbSetup' => null, 'projectConfig' => null, 'fullMock' => false, 'edition' => \Craft::Solo, ]

Application config file must be set.

View source

requiredEvents

Type
array
Default value
[]

For expecting events code

View source

triggeredEvents

Type
array
Default value
[]

For expecting events code

View source

Public Methods

MethodDescription
__construct()Craft constructor.
_afterSuite()
_before()
_beforeSuite()
_initialize()
assertElementsExist()
assertEqualDates()
assertNotPushedToQueue()
assertPushedToQueue()
assertTestFails()
createDbConfig()Creates a DB config according to the loaded .env variables.
createEventItems()
deleteElement()
expectEvent()Ensure that an event is triggered by the $callback() function.
getCodeceptionName()
getFieldLayoutByFieldHandle()
installPlugin()
mockCraftMethods()
mockDbMethods()
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

_before()

View source

Arguments

  • $test (\Codeception\TestInterface)

Throws

_beforeSuite()

View source

Arguments

  • $settings

_initialize()

View source

assertElementsExist()

View source

Arguments

  • $elementType (string)
  • $searchProperties (array)
  • $amount (integer)
  • $searchAll (boolean) – Whether status(null) and trashed(null) should be applied

Returns

array

assertEqualDates()

View source

Arguments

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

Throws

assertNotPushedToQueue()

View source

Arguments

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

deleteElement()

View source

Arguments

Returns

boolean

Throws

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

mockDbMethods()

Since
3.6.11

View source

Arguments

mockMethods()

View source

Arguments

Throws

normalizePathSeparators()

View source

Arguments

  • $path (mixed)

Returns

string, false

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

MethodDescription
addModule()
mockModulesAndPlugins()
recreateClient()
validateEventValue()

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