This library provides EnumAssert
PHPUnit assert for consistence/consistence enums.
$ composer require --dev mhujer/consistence-phpunit
-
use \Mhujer\ConsistencePhpunit\EnumAssert;
-
use the assert this way:
EnumAssert::assertSame($expectedEnum, $actualEnum);
e.g.
public function testEnumsAreSame(): void
{
EnumAssert::assertSame(CardColor::get(CardColor::RED), CardColor::get(CardColor::BLACK));
// Expected "Mhujer\ConsistencePhpunit\Fixtures\CardColor:red", but got "Mhujer\ConsistencePhpunit\Fixtures\CardColor:black
}
Works with PHP 8.1 or higher and PHPUnit 9.3 or higher.
Bugs and feature request are tracked on GitHub
- require PHP 8.1+
- add support for native enums to make migration easier
- require PHP 7.4+
- allow PHP 8.0
- require PHPUnit 9.3+
- allow PHPUnit 9
- initial release