Exemplo n.º 1
0
        context("nested in a context", function () {
            setup(function () {
                transient()->setup3 = true;
            });
            should("have called all three setups", function () {
                assert_equals(true, transient()->setup1);
                assert_equals(true, transient()->setup2);
                assert_equals(true, transient()->setup3);
            });
            should("have the proper test description", function () {
                assert_equals("a context nested in a context nested in a context should have the proper test description", Smoothie::instance()->test_description());
            });
        });
    });
    should("have ran teardown", function () {
        assert_true($GLOBALS['I_RAN_TEARDOWN']);
    });
    context("with no setup", function () {
        should("work", function () {
            assert_true(true);
        });
    });
    // TODO
    should("cause a failure", function () {
        assert_equals(1, 2);
    });
    // TODO
    should("cause an error", function () {
        throw new \Exception("exception!");
    });
});
Exemplo n.º 2
0
<?php

require dirname(__DIR__) . '/ClassMatcher.php';
require __DIR__ . '/Another/World.php';
require __DIR__ . '/Hello/World.php';
require __DIR__ . '/Hello/Comma.php';
require __DIR__ . '/Hello/Separated.php';
require __DIR__ . '/World/Comma.php';
require __DIR__ . '/World/NewLineSeparated.php';
// Thank you https://gist.github.com/mathiasverraes/9046427
function should($e, $a)
{
    echo ($e == $a ? '✔︎' : '✘') . " " . $e . " should match " . $a . "\n";
    if (!($e == $a)) {
        $GLOBALS['f'] = 1;
    }
}
function done()
{
    if (@$GLOBALS['f']) {
        die(1);
    }
}
$expected = array('World' => 'Hello\\World', 'AnotherWorld' => 'Another\\World', 'Comma' => 'Hello\\Comma', 'Separated' => 'Hello\\Separated', 'new Hello\\Separated' => 'Hello\\Separated', 'WorldComma' => 'World\\Comma', 'NewLineSeparated' => 'World\\NewLineSeparated');
$contents = file_get_contents(__DIR__ . '/TestClass.php');
foreach ($expected as $item => $result) {
    $classMatcher = new shameerc\ClassMatcher($contents, $item, $item);
    should($result, $classMatcher->getSuggestedFilename());
}
Exemplo n.º 3
0
            assert_equals("/your regex/", $smoothie->filter);
        });
        should("accept --filter", function () {
            $smoothie = new Smoothie(array("--filter", "your regex"));
            assert_equals("/your regex/", $smoothie->filter);
        });
        should("add slashes if missing", function () {
            $smoothie = new Smoothie(array("-n", "your regex"));
            assert_equals("/your regex/", $smoothie->filter);
        });
        should("not add slahes if already there", function () {
            $smoothie = new Smoothie(array("-n", "/your regex/"));
            assert_equals("/your regex/", $smoothie->filter);
        });
        should("return true if no filter was set", function () {
            $smoothie = new Smoothie();
            assert_true($smoothie->passes_filter("my awesome test"));
        });
        context("tests with passes_filter()", function () {
            setup(function () {
                transient()->smoothie = new Smoothie(array("-n", "/my awesome test/"));
            });
            should("return true if filter was set and passes", function () {
                assert_true(transient()->smoothie->passes_filter("this is my awesome test that is awesome"));
            });
            should("return false if filter was set and does not pass", function () {
                assert_false(transient()->smoothie->passes_filter("blah"));
            });
        });
    });
});