function it_dispatches_SpecificationEvent_before_and_after_examples_run(EventDispatcherInterface $dispatcher, SpecificationNode $specification) { $specification->getExamples()->willReturn(array()); $dispatcher->dispatch('beforeSpecification', Argument::type('PhpSpec\\Event\\SpecificationEvent'))->shouldBeCalled(); $dispatcher->dispatch('afterSpecification', Argument::type('PhpSpec\\Event\\SpecificationEvent'))->shouldBeCalled(); $this->run($specification); }
/** * @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; }