PHP code example of karriere / phpspec-matchers

1. Go to this page and download the library: Download karriere/phpspec-matchers 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/ */

    

karriere / phpspec-matchers example snippets


extensions:
    Karriere\PhpSpecMatchers\Extension: ~

$this->method()->shouldBeAnyOf(1, 2, 3);

$this->method()->shouldNotBeAnyOf(1, 2, 3);

$this->method()->shouldBeAnyOf(2, 3, 4);

// $this->method() may return [1, 2, 3]
$this->method()->shouldBeSomeOf(1, 2, 3, 4, 5);

$this->method()->shouldRangeBetween(2, 4);
$this->method()->shouldRangeBetween(0.1, 0.9);

$this->method()->shouldBeEmpty();

$this->method()->shouldBeNull();

$this->method()->shouldBeLessThan(10);

$this->method()->shouldBeGreaterThan(10);

$this->method()->shouldBeJson();

$this->method()->shouldHaveJsonKey('key');

$this->method()->shouldHaveJsonKey('key.subkey');

$this->method()->shouldHaveJsonKeyWithValue('key.subkey', 'value');