Craft
- Type
- Class
- Namespace
- craft\test
- Inherits
- craft\test\Craft »
Codeception\Module\Yii2
- Since
- 3.2.0
Craft module for codeception
View source (opens new window)
# Public Properties
Property | Description |
---|---|
currentTest | \Codeception\TestInterface |
instance | self – The current instance |
# currentTest
- Type
\Codeception\TestInterface
- Default value
null
View source (opens new window)
# instance
- Type
self
- Default value
null
The current instance
View source (opens new window)
# Protected Properties
Property | Description |
---|---|
addedConfig | array (opens new window) – Application config file must be set. |
requiredEvents | array (opens new window) – For expecting events code |
triggeredEvents | array (opens new window) – For expecting events code |
# addedConfig
- Type
- array (opens new window)
- Default value
[ 'migrations' => [], 'plugins' => [], 'dbSetup' => null, 'projectConfig' => null, 'fullMock' => false, 'edition' => \Craft::Solo, ]
Application config file must be set.
View source (opens new window)
# requiredEvents
- Type
- array (opens new window)
- Default value
[]
For expecting events code
View source (opens new window)
# triggeredEvents
- Type
- array (opens new window)
- Default value
[]
For expecting events code
View source (opens new window)
# 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.
View source (opens new window)
Arguments
$moduleContainer
(\Codeception\Lib\ModuleContainer
)$config
(null (opens new window))
# _afterSuite()
View source (opens new window)
# _before()
View source (opens new window)
Arguments
$test
(\Codeception\TestInterface
)
Throws
- yii\base\InvalidConfigException (opens new window)
- ReflectionException (opens new window)
- Throwable (opens new window)
- yii\base\ErrorException (opens new window)
# _beforeSuite()
View source (opens new window)
Arguments
$settings
# _initialize()
View source (opens new window)
# assertElementsExist()
View source (opens new window)
Arguments
$elementType
(string (opens new window))$searchProperties
(array (opens new window))$amount
(integer (opens new window))$searchAll
(boolean (opens new window)) – Whetherstatus(null)
andtrashed(null)
should be applied
Returns
# assertEqualDates()
View source (opens new window)
Arguments
$test
(\Codeception\TestInterface
)$dateOne
(string (opens new window))$dateTwo
(string (opens new window))$secondsDelta
(float (opens new window))
Throws
# assertNotPushedToQueue()
View source (opens new window)
Arguments
$description
(string (opens new window))
# assertPushedToQueue()
View source (opens new window)
Arguments
$description
(string (opens new window))
# assertTestFails()
View source (opens new window)
Arguments
$callable
(callable (opens new window))$message
(string (opens new window))
# createDbConfig()
Creates a DB config according to the loaded .env variables.
View source (opens new window)
Returns
# createEventItems()
View source (opens new window)
Arguments
$config
(array (opens new window))
Returns
# deleteElement()
View source (opens new window)
Arguments
$element
(craft\base\ElementInterface)$hardDelete
(boolean (opens new window))$failHard
(boolean (opens new window))
Returns
Throws
# expectEvent()
Ensure that an event is triggered by the $callback() function.
View source (opens new window)
Arguments
$class
(string (opens new window))$eventName
(string (opens new window))$callback
(callable (opens new window))$eventInstance
(string (opens new window))$eventValues
(array (opens new window))
# getCodeceptionName()
View source (opens new window)
Returns
# getFieldLayoutByFieldHandle()
View source (opens new window)
Arguments
$fieldHandle
(string (opens new window))
Returns
craft\models\FieldLayout, null (opens new window)
# installPlugin()
View source (opens new window)
Arguments
$plugin
(array (opens new window))
Throws
- yii\base\InvalidConfigException (opens new window)
- Throwable (opens new window)
- craft\errors\InvalidPluginException
# mockCraftMethods()
View source (opens new window)
Arguments
$component
(string (opens new window))$params
(array (opens new window))$constructorParams
(array (opens new window))
Throws
# mockDbMethods()
- Since
- 3.6.11
View source (opens new window)
Arguments
$params
(array (opens new window))
# mockMethods()
View source (opens new window)
Arguments
$module
(yii\base\Module (opens new window))$component
(string (opens new window))$params
(array (opens new window))$constructorParams
(array (opens new window))
Throws
# normalizePathSeparators()
View source (opens new window)
Arguments
$path
(mixed
)
Returns
string (opens new window), false (opens new window)
# resetProjectConfig()
- Since
- 3.3.10
Reset's the project config.
View source (opens new window)
Arguments
$force
(boolean (opens new window)) – 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.
View source (opens new window)
Arguments
$queueItem
(string (opens new window))$params
(array (opens new window))
Throws
# saveElement()
View source (opens new window)
Arguments
$element
(craft\base\ElementInterface)$failHard
(boolean (opens new window))
Returns
Throws
- craft\errors\ElementNotFoundException
- Throwable (opens new window)
- yii\base\Exception (opens new window)
# setupDb()
View source (opens new window)
Throws
# Protected Methods
Method | Description |
---|---|
addModule() | |
mockModulesAndPlugins() | |
recreateClient() | |
validateEventValue() |
# addModule()
View source (opens new window)
Arguments
$test
(\Codeception\PHPUnit\TestCase
)$moduleClass
(string (opens new window))
Throws
# mockModulesAndPlugins()
View source (opens new window)
Arguments
$test
(\Codeception\PHPUnit\TestCase
)
Throws
# recreateClient()
View source (opens new window)
# validateEventValue()
View source (opens new window)
Arguments
$event
(yii\base\Event (opens new window))$eventRequirements
(craft\test\EventItem)