-
Notifications
You must be signed in to change notification settings - Fork 8
Assertions
Isaac Leinweber edited this page Dec 11, 2015
·
1 revision
Each test method is passed an instance of HackPack\HackUnit\Assert
which provides many ways to make assertions in a type safe way. Think of this object as an assertion builder.
After building an assertion object, you make an actual assertion by calling a terminating method, such as is($expected)
. These methods are marked as such in the individual assertion classes below.
As part of the process of checking an assertion, the Test Runner will emit an event to inform any listeners that the assertion passed or failed.
The Assert
object has the following methods to begin your assertions:
bool(bool $actual) : HackPack\HackUnit\Assertion\BoolAssertion
int($actual) : HackPack\HackUnit\Assertion\NumericAssertion<int>
float($actual) : HackPack\HackUnit\Assertion\NumericAssertion<float>
string($actual) : HackPack\HackUnit\Assertion\StringAssertion
mixed($actual) : HackPack\HackUnit\Assertion\MixedAssertion
whenCalled($lambda) : HackPack\HackUnit\Assertion\CallableAssertion
There is only one assertion you can make about a bool: its value.
-
is(bool $expected) : void
- Terminating function - Asserts that
$actual === $expected