Asserts
Special module for using asserts in your tests.
Actions
assertArrayHasKey
param
$keyparam
$actualparam
$description
assertArrayNotHasKey
param
$keyparam
$actualparam
$description
assertContains
Checks that haystack contains needle
param
$needleparam
$haystackparam string
$message
assertEmpty
Checks that variable is empty.
param
$actualparam string
$message
assertEquals
Checks that two variables are equal.
param
$expectedparam
$actualparam string
$message
assertFalse
Checks that condition is negative.
param
$conditionparam string
$message
assertFileExists
Checks if file exists
param string
$filenameparam string
$message
assertFileNotExists
Checks if file doesn't exist
param string
$filenameparam string
$message
assertGreaterOrEquals
param
$expectedparam
$actualparam
$description
assertGreaterThan
Checks that actual is greater than expected
param
$expectedparam
$actualparam string
$message
assertGreaterThanOrEqual
Checks that actual is greater or equal than expected
param
$expectedparam
$actualparam string
$message
assertInstanceOf
param
$classparam
$actualparam
$description
assertInternalType
param
$typeparam
$actualparam
$description
assertIsEmpty
param
$actualparam
$description
assertLessOrEquals
param
$expectedparam
$actualparam
$description
assertLessThan
Checks that actual is less than expected
param
$expectedparam
$actualparam string
$message
assertLessThanOrEqual
Checks that actual is less or equal than expected
param
$expectedparam
$actualparam string
$message
assertNotContains
Checks that haystack doesn't contain needle.
param
$needleparam
$haystackparam string
$message
assertNotEmpty
Checks that variable is not empty.
param
$actualparam string
$message
assertNotEquals
Checks that two variables are not equal
param
$expectedparam
$actualparam string
$message
assertNotInstanceOf
param
$classparam
$actualparam
$description
assertNotNull
Checks that variable is not NULL
param
$actualparam string
$message
assertNotRegExp
Checks that string not match with pattern
param string
$patternparam string
$stringparam string
$message
assertNotSame
Checks that two variables are not same
param
$expectedparam
$actualparam string
$message
assertNull
Checks that variable is NULL
param
$actualparam string
$message
assertRegExp
Checks that string match with pattern
param string
$patternparam string
$stringparam string
$message
assertSame
Checks that two variables are same
param
$expectedparam
$actualparam string
$messagereturn
mixed|void
assertTrue
Checks that condition is positive.
param
$conditionparam string
$message
expectException
Handles 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
fail
Fails the test with message.
param
$message