});
        it('should output time', function () {
            $time = PHP_Timer::secondsToTimeString($this->reporter->getTime());
            assert(strstr($this->contents, $time) !== false, 'should contain time text');
        });
        it('should output failure text', function () {
            assert(strstr($this->contents, '1 failing') !== false, 'should contain failure text');
        });
        it('should output pending count', function () {
            assert(strstr($this->contents, '1 pending') !== false, 'should contain pending text');
        });
        it('should display exception stacks and messages', function () {
            $expectedExceptionMessage = "     ooops" . PHP_EOL . "     nextline";
            assert(strstr($this->contents, $expectedExceptionMessage) !== false, "should include exception message");
            $trace = preg_replace('/^#/m', "      #", $this->exception->getTraceAsString());
            assert(strstr($this->contents, $trace) !== false, "should include exception stack");
        });
        it('should honor peridot exception traces', function () {
            $output = new BufferedOutput();
            $emitter = new EventEmitter();
            $reporter = new SpecReporter($output, $emitter, Context::getInstance());
            $exception = new PeridotException('message');
            $exception->setTraceString('trace!!');
            $emitter->emit('test.failed', new Test('failing test', function () {
            }), $exception);
            $reporter->footer();
            $contents = $output->fetch();
            assert(strstr($contents, 'trace!!') !== false, 'should contain manually set trace');
        });
    });
});
Ejemplo n.º 2
0
             $test->addTearDownFunction(function () {
                 throw new Exception('tear down failure');
             });
             $result = new TestResult(new EventEmitter());
             $test->run($result);
             $expected = "1 run, 1 failed";
             $actual = $result->getSummary();
             assert($expected == $actual, "expected {$expected}, got {$actual}");
         });
         it('should not result in a pass and fail if tear down fails', function () {
             $test = new Test("passing", function () {
             });
             $test->addTearDownFunction(function () {
                 throw new Exception("failure");
             });
             $emitter = new EventEmitter();
             $count = 0;
             $emitter->on('test.passed', function () use(&$count) {
                 $count++;
             });
             $emitter->on('test.failed', function () use(&$count) {
                 $count++;
             });
             $test->run(new TestResult($emitter));
             assert($count == 1, "should not have emitted a pass and fail event");
         });
     });
 });
 describe("->getTitle()", function () {
     it("should return the full text for a spec including parents", function () {
         $root = new Suite("parent", function () {