PHP code example of maxvu / sliver

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

    

maxvu / sliver example snippets



use maxvu\sliver\Test;

$tests = [
    (new Test( function ( $test ) {
        # ...
    } ))->name( '1 + 1 = 2' );
];


$test->assert( $a )->like( $b )       # $a == $b
$test->assert( $a )->eq( $b )         # $a === $b
$test->assert( $a )->ne( $b )         # $a != $b
$test->assert( $a )->gt( $b )         # $a > $b
$test->assert( $a )->ge( $b )         # $a >= $b
$test->assert( $a )->lt( $b )         # $a < $b
$test->assert( $a )->le( $b )         # $a <= $b
$test->assert( $a )->null( $b )       # $a === null
$test->assert( $a )->true( $b )       # $a === true
$test->assert( $a )->false( $b )      # $a === false
$test->assert( $a )->truthy( $b )     # $a
$test->assert( $a )->falsy( $b )      # !$a
$test->assert( $a )->contains( $b )   # in_array( $b, $a ) OR
                                      # false !== strpos( strval( $a ), strval( $b ) )
$test->assert( $a )->matches( $b )    # preg_match( $b, $a );


axvu\sliver\Test;
use maxvu\sliver\ConsoleRunner;

(new ConsoleRunner([
    (new Test( function ( $test ) {
        $test->assert( 1 + 1 )->eq( 2 );
    } ))->name( '1 + 1 = 2' )
]))->show_passing( 1 )->run();

$ php tests.php

    1 + 1 = 2 [ OK ] (0.00045s)

    1 / 1 tests passing (100.00%)
    2 / 2 conditions passing (100.00%)

$