示例#1
0
 public function __invoke()
 {
     $error = new \Error();
     $ok = Result::failed($error);
     Assert::same($ok->isPassed(), false);
     Assert::same($ok->getError(), $error);
 }
 public function __invoke()
 {
     $test = function () {
     };
     $suite = new Suite();
     Assert::same($suite->getTestsCount(), 0);
     $suite = new Suite();
     $suite->addTest($test, 'test1');
     Assert::same($suite->getTestsCount(), 1);
     $suite = new Suite();
     $suite->addTest($test, 'test1');
     $suite->addTest($test, 'test2');
     Assert::same($suite->getTestsCount(), 2);
 }
示例#3
0
 public function __invoke()
 {
     $test = function () {
     };
     $testName = 'testName';
     $suite = new Suite();
     $runTestsCount = 0;
     $testsNames = [];
     $afterSuiteCallback = function ($testNumber, $testName) use(&$runTestsCount, &$testsNames) {
         $testsNames[] = $testName;
         $runTestsCount++;
     };
     $suite->setAfterTestCallback($afterSuiteCallback);
     $suite->addTest($test, $testName);
     $suite(new Runner());
     $expectedTests = [$testName];
     Assert::same($testsNames, $expectedTests);
     Assert::same($runTestsCount, 1);
 }
示例#4
0
 public function __invoke()
 {
     $ok = Result::passed();
     Assert::same($ok->isPassed(), true);
     Assert::same($ok->getError(), null);
 }
示例#5
0
};
$displays_that_test_passes = function () {
    $result = runTestIn(FIXTURES_PATH . '/passes.php');
    $expected = 'ok 1 passes';
    Assert::same($result->getOutput()[1], $expected);
};
$displays_that_test_fails = function () {
    $result = runTestIn(FIXTURES_PATH . '/fails.php');
    $expected = 'not ok 1 fails';
    Assert::same($result->getOutput()[1], $expected);
};
$displays_tests_in_tap_format = function () {
    $result = runTestIn(FIXTURES_PATH . '/two-tests.php');
    $expectedFirst = 'ok 1 test-first';
    $expectedSecond = 'ok 2 test-second';
    Assert::same($result->getOutput()[1], $expectedFirst);
    Assert::same($result->getOutput()[2], $expectedSecond);
};
$returns_0_when_all_tests_passes = function () {
    $result = runTestIn(FIXTURES_PATH . '/passes.php');
    Assert::same($result->getExitCode(), 0);
};
$returns_1_when_one_of_tests_fails = function () {
    $result = runTestIn(FIXTURES_PATH . '/fails.php');
    Assert::same($result->getExitCode(), 1);
};
return ['displays_tap_version' => $displays_tap_version, 'displays_tap_version_if_no_test_were_found' => $displays_only_tap_version_if_no_test_were_found, 'displays_number_of_total_tests_found_1' => function () use($displays_number_of_total_tests_found) {
    $displays_number_of_total_tests_found(FIXTURES_PATH . '/two-tests.php', 2);
}, 'displays_number_of_total_tests_found_2' => function () use($displays_number_of_total_tests_found) {
    $displays_number_of_total_tests_found(FIXTURES_PATH . '/one-test.php', 1);
}, 'displays_that_test_passes' => $displays_that_test_passes, 'displays_that_test_fails' => $displays_that_test_fails, 'displays_tests_in_tap_format' => $displays_tests_in_tap_format, 'returns_0_when_all_tests_passes' => $returns_0_when_all_tests_passes, 'returns_1_when_one_of_tests_fails' => $returns_1_when_one_of_tests_fails];