run() public static method

Run the registered tests, and output a report
See also: FUnit::run_tests()
See also: FUnit::report()
public static run ( boolean $report = true, string $filter = null, $report_format = null )
$report boolean whether or not to output a report after tests run. Default true.
$filter string optional test case name filter
<?php

/**
 * you should run this standalone (not with the test runner)
 */
use FUnit as fu;
use FUnit\TestSuite;
require_once __DIR__ . '/../../src/FUnit.php';
fu::test('FUnit::set_disable_reporting(true)', function () {
    fu::set_disable_reporting(true);
    fu::equal(true, fu::$disable_reporting, "\$disable_reporting is true");
});
fu::set_silence(true);
fu::set_disable_reporting(false);
fu::run();
Beispiel #2
0
    };
    fu::throws($callback, 'RuntimeException', 'Correct exception');
    $callback = function ($foo) {
        throw new RuntimeException($foo);
    };
    fu::throws($callback, array('bar'), 'LogicException', 'Not the correct exception');
});
fu::test('Forced failure', function () {
    fu::fail('This is a forced fail');
});
fu::test('Expected failure', function () {
    fu::expect_fail('This is a good place to describe a missing test');
});
fu::test('Forced Errors/Exception', function () {
    trigger_error('This was triggered inside a test', E_USER_ERROR);
    trigger_error('This was triggered inside a test', E_USER_NOTICE);
    throw new Exception('This was thrown inside a test');
});
fu::test('Checking iterables with all_ok', function () {
    $ints = array(1, 2, 3, 4, 5);
    fu::all_ok($ints, 'is_int', "\$ints are all integers");
    $ints = array(1, 2, 3, "four", 5);
    fu::all_ok($ints, 'is_int', "\$ints are all integers");
    $evens = array('a' => 2, 'b' => 42, 'c' => 68, 'd' => 800);
    $evens_ao = new ArrayObject($evens);
    fu::all_ok($evens_ao, function ($val) {
        return $val % 2 === 0;
    }, "\$evens_ao are all even");
});
$exit = fu::run();
exit($exit);