assert_not_ok() public static method

assert that $a is falsy. Casts $a to boolean for result
public static assert_not_ok ( mixed $a, string $msg = null )
$a mixed the actual value
$msg string optional description of assertion
Exemplo n.º 1
0
    fu::strict_equal(false, fu::assert_ok(null)['result'], "null is falsy");
    fu::strict_equal(false, fu::assert_ok(false)['result'], "false is falsy");
    fu::strict_equal(true, fu::assert_ok(true)['result'], "true is truthy");
    fu::strict_equal(true, fu::assert_ok('false')['result'], "'false' is truthy");
    fu::strict_equal(true, fu::assert_ok(new stdClass())['result'], "stdClass is truthy");
});
fu::test('FUnit::assert_not_ok tests', function () {
    fu::strict_equal(false, fu::assert_not_ok(1)['result'], "1 is truthy");
    fu::strict_equal(true, fu::assert_not_ok(0)['result'], "0 is falsy");
    fu::strict_equal(true, fu::assert_not_ok("")['result'], "empty string is falsy");
    fu::strict_equal(true, fu::assert_not_ok(array())['result'], "empty array is falsy");
    fu::strict_equal(true, fu::assert_not_ok(null)['result'], "null is falsy");
    fu::strict_equal(true, fu::assert_not_ok(false)['result'], "false is falsy");
    fu::strict_equal(false, fu::assert_not_ok(true)['result'], "true is truthy");
    fu::strict_equal(false, fu::assert_not_ok('false')['result'], "'false' is truthy");
    fu::strict_equal(false, fu::assert_not_ok(new stdClass())['result'], "stdClass is truthy");
});
fu::test('FUnit::assert_all_ok tests', function () {
    $all_ints = array(1, 2, 3, 4, 5);
    $not_all_ints = array(1, 2, "3", 4, 5);
    fu::strict_equal(true, fu::assert_all_ok($all_ints, function ($val) {
        return is_int($val);
    })['result'], "\$all_ints are all integers");
    fu::strict_equal(false, fu::assert_all_ok($not_all_ints, function ($val) {
        return is_int($val);
    })['result'], "\$not_all_ints are NOT all integers");
});
fu::test('FUnit::assert_equal tests', function () {
    fu::strict_equal(true, fu::assert_equal(1, 1)['result'], "1 and 1 are 'equal'");
    fu::strict_equal(true, fu::assert_equal("a", "a")['result'], "'a' and 'a' are 'equal'");
    fu::strict_equal(true, fu::assert_equal(new stdClass(), new stdClass())['result'], "new stdClass and new stdClass are 'equal'");