phputil/kahlan

Additional matchers for Kahlan

Maintainers

Package info

github.com/thiagodp/kahlan-matchers

pkg:composer/phputil/kahlan

Transparency log

Statistics

Installs: 55

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 0

v0.3.0 2024-05-15 03:42 UTC

This package is auto-updated.

Last update: 2026-07-29 16:53:45 UTC


README

Additional matchers for Kahlan

Install

Requires PHP 7+ and the extensions pcre and mbstring

composer require phputil/kahlan --dev

See tips for help on how to install extensions.

Matchers

Examples:

// toThrowAnExceptionThatMatches
expect( function() {
    throw new Exception( 'Something went wrong!' );
} )->toThrowAnExceptionThatMatches( '/wrong/' ); // Regular Expression

// toThrowAnExceptionWithCode
expect( function() {
    throw new Exception( 'Something went wrong!', 123 );
} )->toThrowAnExceptionWithCode( 123 ); // Exception code

// toThrowAnExceptionWithClassName ⭐
expect( function() {
    throw new MyOwnException( 'Something went wrong!', 123 );
} )->toThrowAnExceptionWithClassName( MyOwnException::class ); // Exception class

// toHaveStringLength
expect( 'Pelé' )->toHaveStringLength( 4 ); // Compares using mb_strlen() instead of strlen()

Suggestions? Please open an Issue.

License

MIT © Thiago Delgado Pinto