PHP code example of jacobstr / esperance

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

    

jacobstr / esperance example snippets



tion expect($obj) {
    return new \Esperance\Assertion($obj);
}

expect(1)->to->be(1);

echo "All tests passed.", PHP_EOL;


nt = $success = $failure = 0;

function expect($subject) {
    global $count, $success, $failure;

    $extension = new \Esperance\Extension;
    $extension->beforeAssertion(function () use (&$count) {
        $count++;
    });

    return new \Esperance\Assertion($subject, $extension);
}

expect(NULL)->to->be(NULL);
expect(0)->to->be(0);
expect(1)->to->be(1);

echo "Count: {$count}", PHP_EOL; // => Count: 3