PHP code example of rtens / scrut

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

    

rtens / scrut example snippets


class Foo {
    function thisOnePasses() {
        assert(true);
    }
    
    function thisOneFails() {
        assert(false, "Bang");
    }
}

class Foo extends StaticTestSuite {
    function thisOnePasses() {
        $this->assert("1", 1);
    }
    
    function thisOneFails() {
        $this->assert->equals("1", 2);
    }
    
    function thisOneIsEmpty() {
    }
}

return (new GenericTestSuite("Foo"))
    ->test("foo", function (Assert $assert) {
        $assert("1", 1);
    });
    ->test("bar", function (Assert $assert) {
        $assert->equals(1+1, 2);
    });

.F

---- Failed ----
Foo::thisOneFails [/home/derp/scrut/spec/Foo.php:9]
    Caught E_WARNING from /home/derp/scrut/spec/Foo.php:9
    assert(): Bang failed
    
=( 1 Passed, 1 Failed