PHP code example of kahlan / extra-matcher

1. Go to this page and download the library: Download kahlan/extra-matcher library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

kahlan / extra-matcher example snippets


use Kahlan\Extra\Matcher\ExtraMatchers;

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

use Kahlan\Extra\Matcher\ExtraMatchers;

ExtraMatchers::register();

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

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

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');
});