public function runSpecification(Node\Specification $specification)
{
if (defined('PHPSPEC_ERROR_REPORTING')) {
$errorLevel = PHPSPEC_ERROR_REPORTING;
} else {
$errorLevel = E_ALL ^ E_STRICT;
}
$oldHandler = set_error_handler(array($this, 'errorHandler'), $errorLevel);
$this->eventDispatcher->dispatch('beforeSpecification', new Event\SpecificationEvent($specification));
$startTime = microtime(true);
$result = Event\ExampleEvent::PASSED;
foreach ($specification->getChildren() as $child) {
$result = max($result, $this->runExample($child));
}
$this->eventDispatcher->dispatch('afterSpecification', new Event\SpecificationEvent($specification, microtime(true) - $startTime, $result));
if (null !== $oldHandler) {
set_error_handler($oldHandler);
}
return $result;
}