Пример #1
0
function printResultCallback(int $testNumber, string $testName, Result $result)
{
    echo ($result->isPassed() ? "ok" : "not ok") . ' ' . $testNumber . ' ' . $testName . "\n";
    if (!$result->isPassed()) {
        echo $result->getError() . "\n";
    }
}
Пример #2
0
 public function __invoke()
 {
     $error = new \Error();
     $ok = Result::failed($error);
     Assert::same($ok->isPassed(), false);
     Assert::same($ok->getError(), $error);
 }
 public function __invoke()
 {
     $testRunner = new Runner();
     $passingTest = function () {
     };
     $expected = Result::passed();
     Assert::like($testRunner($passingTest), $expected);
 }
 public function __invoke()
 {
     $testRunner = new Runner();
     $error = new \Exception();
     $failingTest = function () use($error) {
         throw $error;
     };
     $expected = Result::failed($error);
     Assert::like($testRunner($failingTest), $expected);
 }
 public function __invoke()
 {
     $suite = new Suite();
     $exception = new \Exception();
     $suite->addTest(function () {
     }, 'passing test 1');
     $suite->addTest(function () {
     }, 'passing test 2');
     $result = $suite(new Runner());
     $expected = Result::passed();
     Assert::like($result, $expected);
 }
 public function __invoke()
 {
     $passingTest = function () {
     };
     $passingTestName = 'passing test';
     $afterTestCallback = function ($testNumber, $testName, $testResult) use(&$spy) {
         $spy = (object) ['testNumber' => $testNumber, 'testName' => $testName, 'testResult' => $testResult];
     };
     $runner = new Runner();
     $suite = new Suite();
     $suite->setAfterTestCallback($afterTestCallback);
     $suite->addTest($passingTest, $passingTestName);
     $suite($runner);
     $expected = new \stdClass();
     $expected->testNumber = 1;
     $expected->testName = $passingTestName;
     $expected->testResult = Result::passed($passingTestName);
     Assert::like($spy, $expected);
 }
Пример #7
0
 public function __invoke()
 {
     $ok = Result::passed();
     Assert::same($ok->isPassed(), true);
     Assert::same($ok->getError(), null);
 }