marcin-orlowski / phpunit-extra-asserts
Extra asserts and helpers to make your unit testing easier.
Installs: 9 529
Dependents: 5
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- marcin-orlowski/type-asserts: ^2.0.0
Requires (Dev)
- phpstan/phpstan: ^1.9.1
- phpunit/php-code-coverage: ^9.0
- phpunit/phpunit: ^9.5.26
README
Collection of additional asserts to be used with PHP Unit testing framework. Helpers are split into dedicated namespaces:
ExtraAsserts
: various asserts to help testing your code,Generator
: various helper methods producing random values for your tests,
Installation
composer require --dev marcin-orlowski/phpunit-extra-asserts
Usage
As ExtraAsserts come as set of static methods so you just need to add related use
to your test
class and all
the methods should be simply available via static reference ExtraAsserts::...
. For example:
use \MarcinOrlowski\PhpunitExtraAsserts\ExtraAsserts; class MyBaseTestClass extends ... { use \MarcinOrlowski\PhpunitExtraAsserts\ExtraAsserts; use \MarcinOrlowski\PhpunitExtraAsserts\Type; [...] public function testSomething(): void { [...] ExtraAsserts::assertIsType($val, [Type::STRING, Type::BOOL]); ExtraAsserts::assertRFC3339($stamp); } }
Available asserts
NOTE: Deprecated methods will be removed in v5.4.0
Helper methods
Generator methods
License
- Written and copyrighted ©2014-2022 by Marcin Orlowski
- Open-sourced software licensed under the MIT license