Special module for using asserts in your tests.
param $keyparam $actualparam $descriptionparam $keyparam $actualparam $descriptionChecks that array contains subset.
param array $subsetparam array $arrayparam bool $strictparam string $messageChecks that haystack contains needle
param $needleparam $haystackparam string $messageparam $expectedCountparam $actualparam $descriptionChecks that variable is empty.
param $actualparam string $messageChecks that two variables are equal. If you're comparing floating-point values, you can specify the optional "delta" parameter which dictates how great of a precision error are you willing to tolerate in order to consider the two values equal.
Regular example:
<?php
$I->assertEquals(5, $element->getChildrenCount());
Floating-point example:
<?php
$I->assertEquals(0.3, $calculator->add(0.1, 0.2), 'Calculator should add the two numbers correctly.', 0.01);
param $expectedparam $actualparam string $messageparam float $deltaChecks that condition is negative.
param $conditionparam string $messageChecks if file exists
param string $filenameparam string $messageChecks if file doesn't exist
param string $filenameparam string $messageparam $expectedparam $actualparam $descriptionChecks that actual is greater than expected
param $expectedparam $actualparam string $messageChecks that actual is greater or equal than expected
param $expectedparam $actualparam string $messageparam $classparam $actualparam $descriptionparam $typeparam $actualparam $descriptionparam $actualparam $descriptionparam $expectedparam $actualparam $descriptionChecks that actual is less than expected
param $expectedparam $actualparam string $messageChecks that actual is less or equal than expected
param $expectedparam $actualparam string $messageChecks that haystack doesn't contain needle.
param $needleparam $haystackparam string $messageChecks that variable is not empty.
param $actualparam string $messageChecks that two variables are not equal. If you're comparing floating-point values, you can specify the optional "delta" parameter which dictates how great of a precision error are you willing to tolerate in order to consider the two values not equal.
Regular example:
<?php
$I->assertNotEquals(0, $element->getChildrenCount());
Floating-point example:
<?php
$I->assertNotEquals(0.4, $calculator->add(0.1, 0.2), 'Calculator should add the two numbers correctly.', 0.01);
param $expectedparam $actualparam string $messageparam float $deltaChecks that the condition is NOT false (everything but false)
param $conditionparam string $messageparam $classparam $actualparam $descriptionChecks that variable is not NULL
param $actualparam string $messageChecks that string not match with pattern
param string $patternparam string $stringparam string $messageChecks that two variables are not same
param $expectedparam $actualparam string $messageChecks that the condition is NOT true (everything but true)
param $conditionparam string $messageChecks that variable is NULL
param $actualparam string $messageChecks that string match with pattern
param string $patternparam string $stringparam string $messageChecks that two variables are same
param $expectedparam $actualparam string $messageChecks that a string doesn't start with the given prefix.
param string $prefixparam string $stringparam string $messageChecks that a string starts with the given prefix.
param string $prefixparam string $stringparam string $messageChecks that condition is positive.
param $conditionparam string $messageHandles and checks exception called inside callback function. Either exception class name or exception instance should be provided.
<?php
$I->expectException(MyException::class, function() {
$this->doSomethingBad();
});
$I->expectException(new MyException(), function() {
$this->doSomethingBad();
});
If you want to check message or exception code, you can pass them with exception instance:
<?php
// will check that exception MyException is thrown with "Don't do bad things" message
$I->expectException(new MyException("Don't do bad things"), function() {
$this->doSomethingBad();
});
param $exception string or \Exceptionparam $callback@deprecated Use expectThrowable instead
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 $throwable string or \Throwableparam $callbackFails the test with message.
param $message