Testomatio - Test Management for Codeception
composer require --dev codeception/module-asserts
Special module for using asserts in your tests.
param int|string
$keyparam array|\ArrayAccess
$arrayparam string
$messageAsserts that an array has a specified key.
param int|string
$keyparam array|\ArrayAccess
$arrayparam string
$messageAsserts that an array does not have a specified key.
param string
$attributeNameparam string
$classNameparam string
$messageAsserts that a class has a specified attribute.
param string
$attributeNameparam string
$classNameparam string
$messageAsserts that a class has a specified static attribute.
param string
$attributeNameparam string
$classNameparam string
$messageAsserts that a class does not have a specified attribute.
param string
$attributeNameparam string
$classNameparam string
$messageAsserts that a class does not have a specified static attribute.
param mixed
$needleparam iterable
$haystackparam string
$messageAsserts that a haystack contains a needle.
param mixed
$needleparam iterable
$haystackparam string
$messageparam string
$typeparam iterable
$haystackparam ?bool
$isNativeTypeparam string
$messageAsserts that a haystack contains only values of a given type.
param string
$classNameparam iterable
$haystackparam string
$messageAsserts that a haystack contains only instances of a given class name.
param int
$expectedCountparam \Countable|iterable
$haystackparam string
$messageAsserts the number of elements of an array, Countable or Traversable.
param string
$directoryparam string
$messageAsserts that a directory does not exist.
param string
$directoryparam string
$messageAsserts that a directory exists.
param string
$directoryparam string
$messageAsserts that a directory exists and is not readable.
param string
$directoryparam string
$messageAsserts that a directory exists and is not writable.
param string
$directoryparam string
$messageAsserts that a directory exists and is readable.
param string
$directoryparam string
$messageAsserts that a directory exists and is writable.
param string
$patternparam string
$stringparam string
$messageAsserts that a string does not match a given regular expression.
param mixed
$actualparam string
$messageAsserts that a variable is empty.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are equal.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are equal (canonicalizing).
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are equal (ignoring case).
param mixed
$expectedparam mixed
$actualparam float
$deltaparam string
$messageAsserts that two variables are equal (with delta).
param mixed
$conditionparam string
$messageAsserts that a condition is false.
param string
$filenameparam string
$messageAsserts that a file does not exist.
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is equal to the contents of another file.
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is equal to the contents of another file (canonicalizing).
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is equal to the contents of another file (ignoring case).
param string
$filenameparam string
$messageAsserts that a file exists.
param string
$fileparam string
$messageAsserts that a file exists and is not readable.
param string
$fileparam string
$messageAsserts that a file exists and is not writable.
param string
$fileparam string
$messageAsserts that a file exists and is readable.
param string
$fileparam string
$messageAsserts that a file exists and is writable.
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is not equal to the contents of another file.
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is not equal to the contents of another file (canonicalizing).
param string
$expectedparam string
$actualparam string
$messageAsserts that the contents of one file is not equal to the contents of another file (ignoring case).
param string
$filenameparam string
$messageAsserts that a file does not exist.
param mixed
$actualparam string
$messageAsserts that a variable is finite.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is greater than or equal to another value.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is greater than another value.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is greater than or equal to another value.
param mixed
$actualparam string
$messageAsserts that a variable is infinite.
param string
$expectedparam mixed
$actualparam string
$messageAsserts that a variable is of a given type.
param mixed
$actualparam string
$messageAsserts that a variable is of type array.
param mixed
$actualparam string
$messageAsserts that a variable is of type bool.
param mixed
$actualparam string
$messageAsserts that a variable is of type callable.
param mixed
$actualparam string
$messageAsserts that a variable is of type resource and is closed.
param mixed
$actualparam string
$messageAsserts that a variable is empty.
param mixed
$actualparam string
$messageAsserts that a variable is of type float.
param mixed
$actualparam string
$messageAsserts that a variable is of type int.
param mixed
$actualparam string
$messageAsserts that a variable is of type iterable.
param mixed
$actualparam string
$messageAsserts that a variable is not of type array.
param mixed
$actualparam string
$messageAsserts that a variable is not of type bool.
param mixed
$actualparam string
$messageAsserts that a variable is not of type callable.
param mixed
$actualparam string
$messageAsserts that a variable is not of type resource.
param mixed
$actualparam string
$messageAsserts that a variable is not of type float.
param mixed
$actualparam string
$messageAsserts that a variable is not of type int.
param mixed
$actualparam string
$messageAsserts that a variable is not of type iterable.
param mixed
$actualparam string
$messageAsserts that a variable is not of type numeric.
param mixed
$actualparam string
$messageAsserts that a variable is not of type object.
param string
$filenameparam string
$messageAsserts that a file/dir exists and is not readable.
param mixed
$actualparam string
$messageAsserts that a variable is not of type resource.
param mixed
$actualparam string
$messageAsserts that a variable is not of type scalar.
param mixed
$actualparam string
$messageAsserts that a variable is not of type string.
param string
$filenameparam string
$messageAsserts that a file/dir exists and is not writable.
param mixed
$actualparam string
$messageAsserts that a variable is of type numeric.
param mixed
$actualparam string
$messageAsserts that a variable is of type object.
param string
$filenameparam string
$messageAsserts that a file/dir is readable.
param mixed
$actualparam string
$messageAsserts that a variable is of type resource.
param mixed
$actualparam string
$messageAsserts that a variable is of type scalar.
param mixed
$actualparam string
$messageAsserts that a variable is of type string.
param string
$filenameparam string
$messageAsserts that a file/dir exists and is writable.
param string
$actualJsonparam string
$messageAsserts that a string is a valid JSON string.
param string
$expectedFileparam string
$actualFileparam string
$messageAsserts that two JSON files are equal.
param string
$expectedFileparam string
$actualFileparam string
$messageAsserts that two JSON files are not equal.
param string
$expectedFileparam string
$actualJsonparam string
$messageAsserts that the generated JSON encoded object and the content of the given file are equal.
param string
$expectedJsonparam string
$actualJsonparam string
$messageAsserts that two given JSON encoded objects or arrays are equal.
param string
$expectedFileparam string
$actualJsonparam string
$messageAsserts that the generated JSON encoded object and the content of the given file are not equal.
param string
$expectedJsonparam string
$actualJsonparam string
$messageAsserts that two given JSON encoded objects or arrays are not equal.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is smaller than or equal to another value.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is smaller than another value.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that a value is smaller than or equal to another value.
param string
$patternparam string
$stringparam string
$messageAsserts that a string matches a given regular expression.
param mixed
$actualparam string
$messageAsserts that a variable is nan.
param mixed
$needleparam iterable
$haystackparam string
$messageAsserts that a haystack does not contain a needle.
param
$needleparam iterable
$haystackparam string
$messageparam string
$typeparam iterable
$haystackparam ?bool
$isNativeTypeparam string
$messageAsserts that a haystack does not contain only values of a given type.
param int
$expectedCountparam \Countable|iterable
$haystackparam string
$messageAsserts the number of elements of an array, Countable or Traversable.
param mixed
$actualparam string
$messageAsserts that a variable is not empty.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are not equal.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are not equal (canonicalizing).
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables are not equal (ignoring case).
param mixed
$expectedparam mixed
$actualparam float
$deltaparam string
$messageAsserts that two variables are not equal (with delta).
param mixed
$conditionparam string
$messageAsserts that a condition is not false.
param string
$expectedparam mixed
$actualparam string
$messageAsserts that a variable is not of a given type.
param mixed
$actualparam string
$messageAsserts that a variable is not null.
param string
$patternparam string
$stringparam string
$messageAsserts that a string does not match a given regular expression.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables do not have the same type and value.
param \Countable|iterable
$expectedparam \Countable|iterable
$actualparam string
$messageAssert that the size of two arrays (or Countable
or Traversable
objects) is not the same.
param mixed
$conditionparam string
$messageAsserts that a condition is not true.
param mixed
$actualparam string
$messageAsserts that a variable is null.
param string
$attributeNameparam object
$objectparam string
$messageAsserts that an object has a specified attribute.
param string
$attributeNameparam object
$objectparam string
$messageAsserts that an object does not have a specified attribute.
param string
$patternparam string
$stringparam string
$messageAsserts that a string matches a given regular expression.
param mixed
$expectedparam mixed
$actualparam string
$messageAsserts that two variables have the same type and value.
param \Countable|iterable
$expectedparam \Countable|iterable
$actualparam string
$messageAssert that the size of two arrays (or Countable
or Traversable
objects) is the same.
param string
$needleparam string
$haystackparam string
$messageparam string
$needleparam string
$haystackparam string
$messageparam string
$suffixparam string
$stringparam string
$messageAsserts that a string ends not with a given suffix.
param string
$suffixparam string
$stringparam string
$messageAsserts that a string ends with a given suffix.
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is equal to the contents of a file.
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is equal to the contents of a file (canonicalizing).
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is equal to the contents of a file (ignoring case).
param string
$formatparam string
$stringparam string
$messageAsserts that a string matches a given format string.
param string
$formatFileparam string
$stringparam string
$messageAsserts that a string matches a given format file.
param string
$needleparam string
$haystackparam string
$messageparam string
$needleparam string
$haystackparam string
$messageparam string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is not equal to the contents of a file.
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is not equal to the contents of a file (canonicalizing).
param string
$expectedFileparam string
$actualStringparam string
$messageAsserts that the contents of a string is not equal to the contents of a file (ignoring case).
param string
$formatparam string
$stringparam string
$messageAsserts that a string does not match a given format string.
param string
$formatFileparam string
$stringparam string
$messageAsserts that a string does not match a given format string.
param string
$prefixparam string
$stringparam string
$messageAsserts that a string starts not with a given prefix.
param string
$prefixparam string
$stringparam string
$messageAsserts that a string starts with a given prefix.
param mixed
$valueparam \PHPUnit\Framework\Constraint\Constraint
$constraintparam string
$messageEvaluates a PHPUnit\Framework\Constraint matcher object.
param mixed
$valueparam \PHPUnit\Framework\Constraint\Constraint
$constraintparam string
$messageEvaluates a PHPUnit\Framework\Constraint matcher object.
param mixed
$conditionparam string
$messageAsserts that a condition is true.
param string
$expectedFileparam string
$actualFileparam string
$messageAsserts that two XML files are equal.
param string
$expectedFileparam string
$actualFileparam string
$messageAsserts that two XML files are not equal.
param string
$expectedFileparam \DOMDocument|string
$actualXmlparam string
$messageAsserts that two XML documents are equal.
param \DOMDocument|string
$expectedXmlparam \DOMDocument|string
$actualXmlparam string
$messageAsserts that two XML documents are equal.
param string
$expectedFileparam \DOMDocument|string
$actualXmlparam string
$messageAsserts that two XML documents are not equal.
param \DOMDocument|string
$expectedXmlparam \DOMDocument|string
$actualXmlparam string
$messageAsserts that two XML documents are not equal.
param \Throwable|string
$throwableparam callable
$callbackreturn void
Handles and checks throwables (Exceptions/Errors) called inside the callback function.
Either throwable class name or throwable instance should be provided.
<?php
$I->expectThrowable(MyThrowable::class, function() {
$this->doSomethingBad();
});
$I->expectThrowable(new MyException(), function() {
$this->doSomethingBad();
});
If you want to check message or throwable code, you can pass them with throwable instance:
<?php
// will check that throwable MyError is thrown with "Don't do bad things" message
$I->expectThrowable(new MyError("Don't do bad things"), function() {
$this->doSomethingBad();
});
param string
$messageFails a test with the given message.
param string
$messageMark the test as incomplete.
param string
$messageMark the test as skipped.