Testomatio - Test Management for Codeception
Codeception\Util\Shared\Asserts
Basic 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 string
Returns a module name for a Module, a class name for Helper
public _hasRequiredFields()
return bool
Checks 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|ModuleException
return void
Allows to redefine config for a specific test.
Config is restored at the end of a test.
public _resetConfig()
return void
Reverts config changed by _reconfigure
public _setConfig(array $config)
param array
$configthrows ModuleConfigException|ModuleException
return void
Allows to define initial module config.
Can be used in _beforeSuite
hook of Helpers or Extensions
protected assert(array $arguments, $not = false)
param array
$argumentsparam bool
$notprotected assertArrayHasKey($key, $array, $message = ββ)
param int|string
$keyparam array|\ArrayAccess
$arrayparam string
$messageAsserts that an array has a specified key.
protected assertArrayNotHasKey($key, $array, $message = ββ)
param int|string
$keyparam array|\ArrayAccess
$arrayparam string
$messageAsserts that an array does not have a specified key.
protected assertClassHasAttribute($attributeName, $className, $message = ββ)
param string
$attributeNameparam string
$classNameparam string
$messageAsserts that a class has a specified attribute.
protected assertClassHasStaticAttribute($attributeName, $className, $message = ββ)
param string
$attributeNameparam string
$classNameparam string
$messageAsserts that a class has a specified static attribute.
protected assertClassNotHasAttribute($attributeName, $className, $message = ββ)
param string
$attributeNameparam string
$classNameparam string
$messageAsserts that a class does not have a specified attribute.
protected assertClassNotHasStaticAttribute($attributeName, $className, $message = ββ)
param string
$attributeNameparam string
$classNameparam string
$messageAsserts that a class does not have a specified static attribute.
protected assertContains($needle, $haystack, $message = ββ)
param mixed
$needleparam iterable
$haystackparam string
$messageAsserts that a haystack contains a needle.
protected assertContainsEquals($needle, $haystack, $message = ββ)
param mixed
$needleparam iterable
$haystackparam string
$messageprotected assertContainsOnly($type, $haystack, $isNativeType = null, $message = ββ)
param string
$typeparam iterable
$haystackparam ?bool
$isNativeTypeparam string
$messageAsserts that a haystack contains only values of a given type.
protected assertContainsOnlyInstancesOf($className, $haystack, $message = ββ)
param string
$classNameparam iterable
$haystackparam string
$messageAsserts that a haystack contains only instances of a given class name.
protected assertCount($expectedCount, $haystack, $message = ββ)
param int
$expectedCountparam \Countable|iterable
$haystackparam string
$messageAsserts the number of elements of an array, Countable or Traversable.
protected assertDirectoryDoesNotExist($directory, $message = ββ)
param string
$directoryparam string
$messageAsserts that a directory does not exist.
protected assertDirectoryExists($directory, $message = ββ)
param string
$directoryparam string
$messageAsserts that a directory exists.
protected assertDirectoryIsNotReadable($directory, $message = ββ)
param string
$directoryparam string
$messageAsserts that a directory exists and is not readable.
protected assertDirectoryIsNotWritable($directory, $message = ββ)
param string
$directoryparam string
$messageAsserts that a directory exists and is not writable.
protected assertDirectoryIsReadable($directory, $message = ββ)
param string
$directoryparam string
$messageAsserts that a directory exists and is readable.
protected assertDirectoryIsWritable($directory, $message = ββ)
param string
$directoryparam string
$messageAsserts that a directory exists and is writable.
protected assertDoesNotMatchRegularExpression($pattern, $string, $message = ββ)
param string
$patternparam string
$stringparam string
$messageAsserts that a string does not match a given regular expression.
protected assertEmpty($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is empty.
protected assertEquals($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are equal.
protected assertEqualsCanonicalizing($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are equal (canonicalizing).
protected assertEqualsIgnoringCase($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are equal (ignoring case).
protected assertEqualsWithDelta($expected, $actual, $delta, $message = ββ)
param mixed
$expectedparam mixed
$actualparam float
$deltaparam string
$messageAsserts that two variables are equal (with delta).
protected assertFalse($condition, $message = ββ)
param mixed
$conditionparam string
$messageAsserts that a condition is false.
protected assertFileDoesNotExist($filename, $message = ββ)
param string
$filenameparam string
$messageAsserts that a file does not exist.
protected assertFileEquals($expected, $actual, $message = ββ)
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is equal to the contents of another file.
protected assertFileEqualsCanonicalizing($expected, $actual, $message = ββ)
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is equal to the contents of another file (canonicalizing).
protected assertFileEqualsIgnoringCase($expected, $actual, $message = ββ)
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is equal to the contents of another file (ignoring case).
protected assertFileExists($filename, $message = ββ)
param string
$filenameparam string
$messageAsserts that a file exists.
protected assertFileIsNotReadable($file, $message = ββ)
param string
$fileparam string
$messageAsserts that a file exists and is not readable.
protected assertFileIsNotWritable($file, $message = ββ)
param string
$fileparam string
$messageAsserts that a file exists and is not writable.
protected assertFileIsReadable($file, $message = ββ)
param string
$fileparam string
$messageAsserts that a file exists and is readable.
protected assertFileIsWritable($file, $message = ββ)
param string
$fileparam string
$messageAsserts that a file exists and is writable.
protected assertFileNotEquals($expected, $actual, $message = ββ)
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is not equal to the contents of another file.
protected assertFileNotEqualsCanonicalizing($expected, $actual, $message = ββ)
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is not equal to the contents of another file (canonicalizing).
protected assertFileNotEqualsIgnoringCase($expected, $actual, $message = ββ)
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is not equal to the contents of another file (ignoring case).
protected assertFileNotExists($filename, $message = ββ)
param string
$filenameparam string
$messageAsserts that a file does not exist.
protected assertFinite($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is finite.
protected assertGreaterOrEquals($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is greater than or equal to another value.
protected assertGreaterThan($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is greater than another value.
protected assertGreaterThanOrEqual($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is greater than or equal to another value.
protected assertInfinite($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is infinite.
protected assertInstanceOf($expected, $actual, $message = ββ)
param string
$expectedparam mixed
$actualparam string
$messageAsserts that a variable is of a given type.
protected assertIsArray($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type array.
protected assertIsBool($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type bool.
protected assertIsCallable($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type callable.
protected assertIsClosedResource($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type resource and is closed.
protected assertIsEmpty($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is empty.
protected assertIsFloat($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type float.
protected assertIsInt($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type int.
protected assertIsIterable($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type iterable.
protected assertIsNotArray($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type array.
protected assertIsNotBool($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type bool.
protected assertIsNotCallable($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type callable.
protected assertIsNotClosedResource($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type resource.
protected assertIsNotFloat($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type float.
protected assertIsNotInt($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type int.
protected assertIsNotIterable($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type iterable.
protected assertIsNotNumeric($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type numeric.
protected assertIsNotObject($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type object.
protected assertIsNotReadable($filename, $message = ββ)
param string
$filenameparam string
$messageAsserts that a file/dir exists and is not readable.
protected assertIsNotResource($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type resource.
protected assertIsNotScalar($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type scalar.
protected assertIsNotString($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not of type string.
protected assertIsNotWritable($filename, $message = ββ)
param string
$filenameparam string
$messageAsserts that a file/dir exists and is not writable.
protected assertIsNumeric($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type numeric.
protected assertIsObject($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type object.
protected assertIsReadable($filename, $message = ββ)
param string
$filenameparam string
$messageAsserts that a file/dir is readable.
protected assertIsResource($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type resource.
protected assertIsScalar($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type scalar.
protected assertIsString($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is of type string.
protected assertIsWritable($filename, $message = ββ)
param string
$filenameparam string
$messageAsserts that a file/dir exists and is writable.
protected assertJson($actualJson, $message = ββ)
param string
$actualJsonparam string
$messageAsserts that a string is a valid JSON string.
protected assertJsonFileEqualsJsonFile($expectedFile, $actualFile, $message = ββ)
param string
$expectedFileparam string
$actualFileparam string
$messageAsserts that two JSON files are equal.
protected assertJsonFileNotEqualsJsonFile($expectedFile, $actualFile, $message = ββ)
param string
$expectedFileparam string
$actualFileparam string
$messageAsserts that two JSON files are not equal.
protected assertJsonStringEqualsJsonFile($expectedFile, $actualJson, $message = ββ)
param string
$expectedFileparam string
$actualJsonparam string
$messageAsserts that the generated JSON encoded object and the content of the given file are equal.
protected assertJsonStringEqualsJsonString($expectedJson, $actualJson, $message = ββ)
param string
$expectedJsonparam string
$actualJsonparam string
$messageAsserts that two given JSON encoded objects or arrays are equal.
protected assertJsonStringNotEqualsJsonFile($expectedFile, $actualJson, $message = ββ)
param string
$expectedFileparam string
$actualJsonparam string
$messageAsserts that the generated JSON encoded object and the content of the given file are not equal.
protected assertJsonStringNotEqualsJsonString($expectedJson, $actualJson, $message = ββ)
param string
$expectedJsonparam string
$actualJsonparam string
$messageAsserts that two given JSON encoded objects or arrays are not equal.
protected assertLessOrEquals($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is smaller than or equal to another value.
protected assertLessThan($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is smaller than another value.
protected assertLessThanOrEqual($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is smaller than or equal to another value.
protected assertMatchesRegularExpression($pattern, $string, $message = ββ)
param string
$patternparam string
$stringparam string
$messageAsserts that a string matches a given regular expression.
protected assertNan($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is nan.
protected assertNot($arguments)
param
$argumentsprotected assertNotContains($needle, $haystack, $message = ββ)
param mixed
$needleparam iterable
$haystackparam string
$messageAsserts that a haystack does not contain a needle.
protected assertNotContainsEquals($needle, $haystack, $message = ββ)
param
$needleparam iterable
$haystackparam string
$messageprotected assertNotContainsOnly($type, $haystack, $isNativeType = null, $message = ββ)
param string
$typeparam iterable
$haystackparam ?bool
$isNativeTypeparam string
$messageAsserts that a haystack does not contain only values of a given type.
protected assertNotCount($expectedCount, $haystack, $message = ββ)
param int
$expectedCountparam \Countable|iterable
$haystackparam string
$messageAsserts the number of elements of an array, Countable or Traversable.
protected assertNotEmpty($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not empty.
protected assertNotEquals($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are not equal.
protected assertNotEqualsCanonicalizing($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are not equal (canonicalizing).
protected assertNotEqualsIgnoringCase($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are not equal (ignoring case).
protected assertNotEqualsWithDelta($expected, $actual, $delta, $message = ββ)
param mixed
$expectedparam mixed
$actualparam float
$deltaparam string
$messageAsserts that two variables are not equal (with delta).
protected assertNotFalse($condition, $message = ββ)
param mixed
$conditionparam string
$messageAsserts that a condition is not false.
protected assertNotInstanceOf($expected, $actual, $message = ββ)
param string
$expectedparam mixed
$actualparam string
$messageAsserts that a variable is not of a given type.
protected assertNotNull($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is not null.
protected assertNotRegExp($pattern, $string, $message = ββ)
param string
$patternparam string
$stringparam string
$messageAsserts that a string does not match a given regular expression.
protected assertNotSame($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables do not have the same type and value.
protected assertNotSameSize($expected, $actual, $message = ββ)
param \Countable|iterable
$expectedparam \Countable|iterable
$actualparam string
$messageAssert that the size of two arrays (or Countable
or Traversable
objects) is not the same.
protected assertNotTrue($condition, $message = ββ)
param mixed
$conditionparam string
$messageAsserts that a condition is not true.
protected assertNull($actual, $message = ββ)
param mixed
$actualparam string
$messageAsserts that a variable is null.
protected assertObjectHasAttribute($attributeName, $object, $message = ββ)
param string
$attributeNameparam object
$objectparam string
$messageAsserts that an object has a specified attribute.
protected assertObjectNotHasAttribute($attributeName, $object, $message = ββ)
param string
$attributeNameparam object
$objectparam string
$messageAsserts that an object does not have a specified attribute.
protected assertRegExp($pattern, $string, $message = ββ)
param string
$patternparam string
$stringparam string
$messageAsserts that a string matches a given regular expression.
protected assertSame($expected, $actual, $message = ββ)
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables have the same type and value.
protected assertSameSize($expected, $actual, $message = ββ)
param \Countable|iterable
$expectedparam \Countable|iterable
$actualparam string
$messageAssert that the size of two arrays (or Countable
or Traversable
objects) is the same.
protected assertStringContainsString($needle, $haystack, $message = ββ)
param string
$needleparam string
$haystackparam string
$messageprotected assertStringContainsStringIgnoringCase($needle, $haystack, $message = ββ)
param string
$needleparam string
$haystackparam string
$messageprotected assertStringEndsNotWith($suffix, $string, $message = ββ)
param string
$suffixparam string
$stringparam string
$messageAsserts that a string ends not with a given suffix.
protected assertStringEndsWith($suffix, $string, $message = ββ)
param string
$suffixparam string
$stringparam string
$messageAsserts that a string ends with a given suffix.
protected assertStringEqualsFile($expectedFile, $actualString, $message = ββ)
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is equal to the contents of a file.
protected assertStringEqualsFileCanonicalizing($expectedFile, $actualString, $message = ββ)
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is equal to the contents of a file (canonicalizing).
protected assertStringEqualsFileIgnoringCase($expectedFile, $actualString, $message = ββ)
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is equal to the contents of a file (ignoring case).
protected assertStringMatchesFormat($format, $string, $message = ββ)
param string
$formatparam string
$stringparam string
$messageAsserts that a string matches a given format string.
protected assertStringMatchesFormatFile($formatFile, $string, $message = ββ)
param string
$formatFileparam string
$stringparam string
$messageAsserts that a string matches a given format file.
protected assertStringNotContainsString($needle, $haystack, $message = ββ)
param string
$needleparam string
$haystackparam string
$messageprotected assertStringNotContainsStringIgnoringCase($needle, $haystack, $message = ββ)
param string
$needleparam string
$haystackparam string
$messageprotected assertStringNotEqualsFile($expectedFile, $actualString, $message = ββ)
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is not equal to the contents of a file.
protected assertStringNotEqualsFileCanonicalizing($expectedFile, $actualString, $message = ββ)
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is not equal to the contents of a file (canonicalizing).
protected assertStringNotEqualsFileIgnoringCase($expectedFile, $actualString, $message = ββ)
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is not equal to the contents of a file (ignoring case).
protected assertStringNotMatchesFormat($format, $string, $message = ββ)
param string
$formatparam string
$stringparam string
$messageAsserts that a string does not match a given format string.
protected assertStringNotMatchesFormatFile($formatFile, $string, $message = ββ)
param string
$formatFileparam string
$stringparam string
$messageAsserts that a string does not match a given format string.
protected assertStringStartsNotWith($prefix, $string, $message = ββ)
param string
$prefixparam string
$stringparam string
$messageAsserts that a string starts not with a given prefix.
protected assertStringStartsWith($prefix, $string, $message = ββ)
param string
$prefixparam string
$stringparam string
$messageAsserts that a string starts with a given prefix.
protected assertThat($value, $constraint, $message = ββ)
param mixed
$valueparam \PHPUnit\Framework\Constraint\Constraint
$constraintparam string
$messageEvaluates a PHPUnit\Framework\Constraint matcher object.
protected assertThatItsNot($value, $constraint, $message = ββ)
param mixed
$valueparam \PHPUnit\Framework\Constraint\Constraint
$constraintparam string
$messageEvaluates a PHPUnit\Framework\Constraint matcher object.
protected assertTrue($condition, $message = ββ)
param mixed
$conditionparam string
$messageAsserts that a condition is true.
protected assertXmlFileEqualsXmlFile($expectedFile, $actualFile, $message = ββ)
param string
$expectedFileparam string
$actualFileparam string
$messageAsserts that two XML files are equal.
protected assertXmlFileNotEqualsXmlFile($expectedFile, $actualFile, $message = ββ)
param string
$expectedFileparam string
$actualFileparam string
$messageAsserts that two XML files are not equal.
protected assertXmlStringEqualsXmlFile($expectedFile, $actualXml, $message = ββ)
param string
$expectedFileparam \DOMDocument|string
$actualXmlparam string
$messageAsserts that two XML documents are equal.
protected assertXmlStringEqualsXmlString($expectedXml, $actualXml, $message = ββ)
param \DOMDocument|string
$expectedXmlparam \DOMDocument|string
$actualXmlparam string
$messageAsserts that two XML documents are equal.
protected assertXmlStringNotEqualsXmlFile($expectedFile, $actualXml, $message = ββ)
param string
$expectedFileparam \DOMDocument|string
$actualXmlparam string
$messageAsserts that two XML documents are not equal.
protected assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, $message = ββ)
param \DOMDocument|string
$expectedXmlparam \DOMDocument|string
$actualXmlparam string
$messageAsserts that two XML documents are not equal.
protected debug($message)
param mixed
$messagereturn void
Print debug message to the screen.
protected debugSection($title, $message)
param string
$titleparam mixed
$messagereturn void
Print debug message with a title
protected fail($message = ββ)
param string
$messageFails a test with the given message.
protected getModule($name)
param string
$namethrows ModuleException
return \Codeception\Module
Get another module by its name:
protected getModules()
return array
Get all enabled modules
protected hasModule($name)
param string
$namereturn bool
Checks that module is enabled.
protected markTestIncomplete($message = ββ)
param string
$messageMark the test as incomplete.
protected markTestSkipped($message = ββ)
param string
$messageMark the test as skipped.
protected onReconfigure()
HOOK to be executed when config changes with _reconfigure
.
protected scalarizeArray(array $array)
param array
$arrayreturn array
protected shortenMessage($message, $chars = 150)
param string
$messageparam int
$charsreturn string
Short text message to an amount of chars
protected validateConfig()
throws ModuleConfigException|ModuleException
return void
Validates current config for required fields and required packages.