Testomatio - Test Management for Codeception
Codeception\Util\Shared\AssertsBasic class for Modules and Helpers. You must extend from it while implementing own helpers.
Public methods of this class start with _ prefix in order to ignore them in actor classes.
Module contains HOOKS which allow to handle test execution routine.
public static $includeInheritedActions
By setting it to false module wanβt inherit methods of parent class.
public static $onlyActions
Allows to explicitly set what methods have this class.
public static $excludeActions
Allows to explicitly exclude actions from module.
public static $aliases
Allows to rename actions
public __construct($moduleContainer, array $config = null)
param \Codeception\Lib\ModuleContainer $moduleContainerparam ?array $configModule constructor.
Requires module container (to provide access between modules of suite) and config.
public _after($test)
param \Codeception\TestInterface $testHOOK executed after test
public _afterStep($step)
param \Codeception\Step $stepHOOK executed after step
public _afterSuite()
HOOK executed after suite
public _before($test)
param \Codeception\TestInterface $testHOOK executed before test
public _beforeStep($step)
param \Codeception\Step $stepHOOK executed before step
public _beforeSuite(array $settings = array ( ))
param array $settingsHOOK executed before suite
public _failed($test, $fail)
param \Codeception\TestInterface $testparam \Exception $failHOOK executed when test fails but before _after
public _getConfig($key = null)
param string|null $keyreturn mixed the config itemβs value or null if it doesnβt existGet config values or specific config item.
public _getName()
return stringReturns a module name for a Module, a class name for Helper
public _hasRequiredFields()
return boolChecks if a module has required fields
public _initialize()
HOOK triggered after module is created and configuration is loaded
public _reconfigure(array $config)
param array $configthrows ModuleConfigException|ModuleExceptionreturn voidAllows to redefine config for a specific test.
Config is restored at the end of a test.
<?php
// cleanup DB only for specific group of tests
public function _before(Test $test) {
if (in_array('cleanup', $test->getMetadata()->getGroups()) {
$this->getModule('Db')->_reconfigure(['cleanup' => true]);
}
}public _resetConfig()
return voidReverts config changed by _reconfigure
public _setConfig(array $config)
param array $configthrows ModuleConfigException|ModuleExceptionreturn voidAllows to define initial module config.
Can be used in _beforeSuite hook of Helpers or Extensions
<?php
public function _beforeSuite($settings = []) {
$this->getModule('otherModule')->_setConfig($this->myOtherConfig);
}protected assert(array $arguments, $not = false)
param array $argumentsparam bool $notreturn voidprotected assertArrayHasKey($key, $array, $message = ββ)
param string|int $keyparam \ArrayAccess|array $arrayparam string $messagereturn voidAsserts that an array has a specified key.
protected assertArrayNotHasKey($key, $array, $message = ββ)
param string|int $keyparam \ArrayAccess|array $arrayparam string $messagereturn voidAsserts that an array does not have a specified key.
protected assertClassHasAttribute($attributeName, $className, $message = ββ)
param string $attributeNameparam class-string $classNameparam string $messagereturn voidAsserts that a class has a specified attribute.
protected assertClassHasStaticAttribute($attributeName, $className, $message = ββ)
param string $attributeNameparam class-string $classNameparam string $messagereturn voidAsserts that a class has a specified static attribute.
protected assertClassNotHasAttribute($attributeName, $className, $message = ββ)
param string $attributeNameparam class-string $classNameparam string $messagereturn voidAsserts that a class does not have a specified attribute.
protected assertClassNotHasStaticAttribute($attributeName, $className, $message = ββ)
param string $attributeNameparam class-string $classNameparam string $messagereturn voidAsserts that a class does not have a specified static attribute.
protected assertContains($needle, $haystack, $message = ββ)
param mixed $needleparam iterable<mixed> $haystackparam string $messagereturn voidAsserts that a haystack contains a needle.