function it_returns_examples_max_resultCode(SpecificationNode $specification, ExampleNode $ex1, ExampleNode $ex2, ExampleRunner $exampleRunner) { $specification->getExamples()->willReturn(array($ex1, $ex2)); $exampleRunner->run($ex1)->willReturn(2); $exampleRunner->run($ex2)->willReturn(0); $this->run($specification)->shouldReturn(2); }
/** * @param SpecificationNode $specification * @return int|mixed */ public function run(SpecificationNode $specification) { $startTime = microtime(true); $this->dispatcher->dispatch('beforeSpecification', new Event\SpecificationEvent($specification)); $result = Event\ExampleEvent::PASSED; foreach ($specification->getExamples() as $example) { $result = max($result, $this->exampleRunner->run($example)); } $this->dispatcher->dispatch('afterSpecification', new Event\SpecificationEvent($specification, microtime(true) - $startTime, $result)); return $result; }