PHP code example of pyrsmk / minisuite

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

    

pyrsmk / minisuite example snippets


$fruits = ['apple', 'peach', 'strawberry'];

$minisuite = new MiniSuite\Suite('My tests');
$minisuite->expects('I have 3 fruits in my basket') // define the expectation message
          ->that(count($fruits))                    // define the value to verify
          ->equals(3);                              // 'equals' expectation

$some_value = 72;

$minisuite->expects('Some message')
          ->that($some_value)
          ->isInteger()
          ->isGreaterThan(0)
          ->isLessThanOrEqual(100);

$fruits = ['apples' => 12, 'peaches' => 7, 'strawberries' => 41];

$minisuite->expects('Verify strawberries stock')
          ->that($fruits, 'strawberries')
          ->isDefined()
          ->isInteger()
          ->isGreaterThan(0);

$minisuite->expects('Test')
          ->that(function($minisuite) {
              return 72;
          })
          ->equals(72);

$minisuite->expects('Test')
          ->that($minisuite->protect(function($minisuite) {
              throws Exception();
          }))
          ->throws();

$minisuite['fruits'] = ['apples' => 12, 'peaches' => 7, 'strawberries' => 41];

$minisuite->expects('Verify strawberries stock')
          ->that(function($minisuite) {
              return count($minisuite['fruits']['strawberries']) > 0;
          })
          ->equals(true);

$minisuite = new MiniSuite\Suite('My tests');

// Init configuration
$minisuite['conf'] = [
    'path' => 'some/path/'
];

// Set hydrate function
$minisuite->hydrate(function($minisuite) {
    $minisuite['logger'] = new SomeLogger($minisuite['conf']);
});

// Test the logger
$minisuite->expects('Verify logger path')
          ->that(function($minisuite) {
              return $minisuite['logger']->getPath();
          })
          ->equals('some/path/');