Craft ​
- Type
- Class
- Namespace
- craft\test
- Inherits
- craft\test\Craft »
Codeception\Module\Yii2
- Since
- 3.2.0
Craft module for codeception
Public Properties ​
Property | Description |
---|---|
currentTest | \Codeception\TestInterface |
instance | self – The current instance |
currentTest
​
- Type
\Codeception\TestInterface
- Default value
null
instance
​
- Type
self
- Default value
null
The current instance
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
- Default value
[ 'migrations' => [], 'plugins' => [], 'dbSetup' => null, 'projectConfig' => null, 'fullMock' => false, 'edition' => \craft\enums\CmsEdition::Pro->value, ]
Application config file must be set.
requiredEvents
​
- Type
- array
- Default value
[]
For expecting events code
triggeredEvents
​
- Type
- array
- Default value
[]
For expecting events code
Public Methods ​
Method | Description |
---|---|
__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.
Arguments ​
$moduleContainer
(\Codeception\Lib\ModuleContainer
)$config
(null)
_afterSuite()
​
_before()
​
Arguments ​
$test
(\Codeception\TestInterface
)
Throws ​
_beforeSuite()
​
Arguments ​
$settings
_initialize()
​
assertElementsExist()
​
Arguments ​
$elementType
(string)$searchProperties
(array)$amount
(integer)$searchAll
(boolean) – Whetherstatus(null)
andtrashed(null)
should be applied
Returns ​
assertEqualDates()
​
Arguments ​
Throws ​
assertNotPushedToQueue()
​
Arguments ​
$description
(string)
assertPushedToQueue()
​
Arguments ​
$description
(string)
assertTestFails()
​
Arguments ​
createDbConfig()
​
Creates a DB config according to the loaded .env variables.
Returns ​
createEventItems()
​
Arguments ​
$config
(array)
Returns ​
deleteElement()
​
Arguments ​
$element
(craft\base\ElementInterface)$hardDelete
(boolean)$failHard
(boolean)
Returns ​
Throws ​
expectEvent()
​
Ensure that an event is triggered by the $callback() function.
Arguments ​
getCodeceptionName()
​
Returns ​
getFieldLayoutByFieldHandle()
​
Arguments ​
$fieldHandle
(string)
Returns ​
craft\models\FieldLayout, null
installPlugin()
​
Arguments ​
$plugin
(array)
Throws ​
mockCraftMethods()
​
Arguments ​
Throws ​
mockDbMethods()
​
- Since
- 3.6.11
Arguments ​
$params
(array)
mockMethods()
​
Arguments ​
$module
(yii\base\Module)$component
(string)$params
(array)$constructorParams
(array)
Throws ​
normalizePathSeparators()
​
Arguments ​
$path
(mixed
)
Returns ​
resetProjectConfig()
​
- Since
- 3.3.10
Reset's the project config.
Arguments ​
$force
(boolean) – Whether to force the reset. If set to true thereset
key of the projectConfig configuration will be ignored and the project config will be reset regardless.
Returns ​
runQueue()
​
An easy way of handling the testing of queue jobs.
Arguments ​
Throws ​
saveElement()
​
Arguments ​
$element
(craft\base\ElementInterface)$failHard
(boolean)
Returns ​
Throws ​
setupDb()
​
Throws ​
Protected Methods ​
Method | Description |
---|---|
addModule() | |
mockModulesAndPlugins() | |
recreateClient() | |
validateEventValue() |
addModule()
​
Arguments ​
$test
(\Codeception\PHPUnit\TestCase
)$moduleClass
(string)
Throws ​
mockModulesAndPlugins()
​
Arguments ​
$test
(\Codeception\PHPUnit\TestCase
)
Throws ​
recreateClient()
​
validateEventValue()
​
Arguments ​
$event
(yii\base\Event)$eventRequirements
(craft\test\EventItem)