peridot-php / leo
Next level assertion and matcher library for PHP
Installs: 327 273
Dependents: 64
Suggesters: 0
Security: 0
Stars: 35
Watchers: 5
Forks: 7
Open Issues: 6
Requires
- php: >=5.4
Requires (Dev)
This package is not auto-updated.
Last update: 2024-12-21 17:41:33 UTC
README
Leo
Next level assertion library for PHP
Visit the main site and documentation at peridot-php.github.io/leo/.
Expect Interface
Leo supports a chainable interface for writing assertions via the expect
function:
expect($obj)->to->have->property('name'); expect($value)->to->be->ok expect($fn)->to->throw('InvalidArgumentException', 'Expected message'); expect($array)->to->be->an('array'); expect($result)->to->not->be->empty;
Assert Interface
Leo supports a more object oriented, non-chainable interface via Assert
:
use Peridot\Leo\Interfaces\Assert; $assert = new Assert(); $assert->ok(true); $assert->doesNotThrow($fn, 'Exception'); $assert->isResource(tmpfile()); $assert->notEqual($actual, $expected);
Detailed error messages
Leo matchers generate detailed error messages for failed assertions:
Plugins
Leo can be easily customized. For an example see LeoHttpFoundation. Read more on the plugin guide.
Running Tests
make test
Generating Docs
Documentation is generated via ApiGen. Simply run:
make docs
Thanks
Leo was inspired by several great projects:
- Chai for JS
- Jasmine for JS
- Espérance for PHP
- Pho for PHP
And of course our work on Peridot gave incentive to make a useful complement.