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.
type bool
public static $onlyActions
Allows to explicitly set what methods have this class.
type array
public static $excludeActions
Allows to explicitly exclude actions from module.
type array
public static $aliases
Allows to rename actions
type array
public __construct($moduleContainer, $config = null)
Module constructor.
Requires module container (to provide access between modules of suite) and config.
param ModuleContainer $moduleContainerparam null $configpublic _after($test)
HOOK executed after test
param TestInterface $testpublic _afterStep($step)
HOOK executed after step
param Step $steppublic _afterSuite()
HOOK executed after suite
public _before($test)
HOOK executed before test
param TestInterface $testpublic _beforeStep($step)
HOOK executed before step
param Step $steppublic _beforeSuite($settings = null)
HOOK executed before suite
param array $settingspublic _failed($test, $fail)
HOOK executed when test fails but before _after
param TestInterface $testparam \Exception $failpublic _getConfig($key = null)
Get config values or specific config item.
param null $keyreturn array|mixed|nullpublic _getName()
Returns a module name for a Module, a class name for Helper
return stringpublic _hasRequiredFields()
Checks if a module has required fields
return boolpublic _initialize()
HOOK triggered after module is created and configuration is loaded
public _reconfigure($config)
Allows 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]);
}
}
param $configthrows Exception\ModuleConfigExceptionthrows ModuleExceptionpublic _resetConfig()
Reverts config changed by _reconfigure
public _setConfig($config)
Allows 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);
}
param $configthrows Exception\ModuleConfigExceptionthrows ModuleExceptionprotected assert($arguments, $not = null)
protected assertArrayHasKey($key, $actual, $description = null)
param $keyparam $actualparam $descriptionprotected assertArrayNotHasKey($key, $actual, $description = null)
param $keyparam $actualparam $descriptionprotected assertArraySubset($subset, $array, $strict = null, $message = null)
Checks that array contains subset.
param array $subsetparam array $arrayparam bool $strictparam string $messageprotected assertContains($needle, $haystack, $message = null)
Checks that haystack contains needle
param $needleparam $haystackparam string $messageprotected assertCount($expectedCount, $actual, $description = null)
param $expectedCountparam $actualparam $descriptionprotected assertEmpty($actual, $message = null)
Checks that variable is empty.
param $actualparam string $messageprotected assertEquals($expected, $actual, $message = null, $delta = null)
Checks that two variables are equal.
param $expectedparam $actualparam string $messageparam float $deltaprotected assertFalse($condition, $message = null)
Checks that condition is negative.
param $conditionparam string $messageprotected assertFileExists($filename, $message = null)
Checks if file exists
param string $filenameparam string $messageprotected assertFileNotExists($filename, $message = null)
Checks if file doesn't exist
param string $filenameparam string $messageprotected assertGreaterOrEquals($expected, $actual, $description = null)
param $expectedparam $actualparam $descriptionprotected assertGreaterThan($expected, $actual, $message = null)
Checks that actual is greater than expected
param $expectedparam $actualparam string $messageprotected assertGreaterThanOrEqual($expected, $actual, $message = null)
Checks that actual is greater or equal than expected
param $expectedparam $actualparam string $messageprotected assertGreaterThen($expected, $actual, $message = null)
deprecated
See sourceprotected assertGreaterThenOrEqual($expected, $actual, $message = null)
deprecated
See sourceprotected assertInstanceOf($class, $actual, $description = null)
param $classparam $actualparam $descriptionprotected assertInternalType($type, $actual, $description = null)
param $typeparam $actualparam $descriptionprotected assertIsEmpty($actual, $description = null)
param $actualparam $descriptionprotected assertLessOrEquals($expected, $actual, $description = null)
param $expectedparam $actualparam $descriptionprotected assertLessThan($expected, $actual, $message = null)
Checks that actual is less than expected
param $expectedparam $actualparam string $messageprotected assertLessThanOrEqual($expected, $actual, $message = null)
Checks that actual is less or equal than expected
param $expectedparam $actualparam string $messageprotected assertNot($arguments)
protected assertNotContains($needle, $haystack, $message = null)
Checks that haystack doesn't contain needle.
param $needleparam $haystackparam string $messageprotected assertNotEmpty($actual, $message = null)
Checks that variable is not empty.
param $actualparam string $messageprotected assertNotEquals($expected, $actual, $message = null, $delta = null)
Checks that two variables are not equal
param $expectedparam $actualparam string $messageparam float $deltaprotected assertNotInstanceOf($class, $actual, $description = null)
param $classparam $actualparam $descriptionprotected assertNotNull($actual, $message = null)
Checks that variable is not NULL
param $actualparam string $messageprotected assertNotRegExp($pattern, $string, $message = null)
Checks that string not match with pattern
param string $patternparam string $stringparam string $messageprotected assertNotSame($expected, $actual, $message = null)
Checks that two variables are not same
param $expectedparam $actualparam string $messageprotected assertNull($actual, $message = null)
Checks that variable is NULL
param $actualparam string $messageprotected assertRegExp($pattern, $string, $message = null)
Checks that string match with pattern
param string $patternparam string $stringparam string $messageprotected assertSame($expected, $actual, $message = null)
Checks that two variables are same
param $expectedparam $actualparam string $messageprotected assertStringStartsNotWith($prefix, $string, $message = null)
Checks that a string doesn't start with the given prefix.
param string $prefixparam string $stringparam string $messageprotected assertStringStartsWith($prefix, $string, $message = null)
Checks that a string starts with the given prefix.
param string $prefixparam string $stringparam string $messageprotected assertThat($haystack, $constraint, $message = null)
param $haystackparam $constraintparam string $messageprotected assertThatItsNot($haystack, $constraint, $message = null)
Checks that haystack doesn't attend
param $haystackparam $constraintparam string $messageprotected assertTrue($condition, $message = null)
Checks that condition is positive.
param $conditionparam string $messageprotected debug($message)
Print debug message to the screen.
param $messageprotected debugSection($title, $message)
Print debug message with a title
param $titleparam $messageprotected fail($message)
Fails the test with message.
param $messageprotected getModule($name)
Get another module by its name:
<?php
$this->getModule('WebDriver')->_findElements('.items');
param $namereturn Modulethrows ModuleExceptionprotected getModules()
Get all enabled modules
return arrayprotected hasModule($name)
Checks that module is enabled.
param $namereturn boolprotected onReconfigure()
HOOK to be executed when config changes with _reconfigure.
protected scalarizeArray($array)
protected validateConfig()
Validates current config for required fields and required packages.
throws Exception\ModuleConfigExceptionthrows ModuleException