kahlan/extra-matcher

Additional matchers for Kahlan.

Installs: 1 472

Dependents: 5

Suggesters: 0

Security: 0

Stars: 6

Watchers: 6

Forks: 2

Open Issues: 0

pkg:composer/kahlan/extra-matcher

1.0.0 2017-04-07 12:53 UTC

This package is auto-updated.

Last update: 2025-09-29 01:49:42 UTC


README

Build Status Code Coverage

Installation

via Composer

$ composer require --dev kahlan/extra-matcher

Registration

To manually register the matchers you want, add them in your kahlan-config.php config file like in the following example:

use Kahlan\Extra\Matcher\ExtraMatchers;

ExtraMatchers::register(['toBeOneOf', ...]);

Or in case you want to register all matchers, you can simply write:

use Kahlan\Extra\Matcher\ExtraMatchers;

ExtraMatchers::register();

Documentation

toBeOneOf($expected) // strict comparison

it("passes if $actual is present in $expected", function() {
    expect(3)->toBeOneOf([1, 2, 3]);
});

toEqualOneOf($expected) // loose comparison

it("passes if $actual is present in $expected", function() {
    expect("3")->toEqualOneOf([1, 2, 3]);
});

toImplement($expected) // object implements expected interface

namespace App\Spec;

it("passes if $actual implements $expected", function() {

    interface Foo { }
    class Bar implements Foo {}

    $actual = new Bar();
    expect($actual)->toImplement('App\Spec\Foo');
});