}); it('should emit exception and title data with event', function () { $suite = new Suite("Parents", function () { }); $test = new Test('should have children'); $suite->addTest($test); $exception = new RuntimeException('a failure'); $tmpfile = tmpfile(); $message = new TestMessage($tmpfile); $message->setTest($test)->setEvent('test.failed')->setException($exception)->write(); fseek($tmpfile, 0); $content = fread($tmpfile, 8192); $receivedTest = null; $receivedException = null; $message->on('test.failed', function ($t, $e) use(&$receivedTest, &$receivedException) { $receivedTest = $t; $receivedException = $e; }); $message->emit('data', [$content]); expect($receivedTest->getDescription())->to->equal('should have children'); expect($receivedTest->getTitle())->to->equal('Parents should have children'); expect($receivedException->getMessage())->to->equal($exception->getMessage()); expect($receivedException->getTraceAsString())->to->equal($exception->getTraceAsString()); }); }); context('and the data represents a suite', function () { beforeEach(function () { $test = new Suite('description', function () { }); $this->message->setTest($test)->setEvent('suite.started')->write(); fseek($this->tmpfile, 0); $this->content = fread($this->tmpfile, 4096);