/** * Adds a simple step to current test case * @param string $name step name * @param callable $logic anonymous function containing the entire step logic. * @param string $title an optional title for the step * @return mixed * @throws \Yandex\Allure\Adapter\AllureException * @throws \Exception */ public function executeStep($name, $logic, $title = null) { $logicResult = null; if (isset($name) && is_callable($logic)) { $event = new StepStartedEvent($name); if (isset($title)) { $event->withTitle($title); } else { $event->withTitle($name); } Allure::lifecycle()->fire($event); try { $logicResult = $logic(); Allure::lifecycle()->fire(new StepFinishedEvent()); } catch (Exception $e) { $stepFailedEvent = new StepFailedEvent(); Allure::lifecycle()->fire($stepFailedEvent); Allure::lifecycle()->fire(new StepFinishedEvent()); throw $e; } } else { throw new AllureException("Step name shouldn't be null and logic should be a callable."); } return $logicResult; }
public function testEvent() { $step = new Step(); $stepName = 'step-name'; $stepTitle = 'step-title'; $event = new StepStartedEvent($stepName); $event->withTitle($stepTitle); $event->process($step); $this->assertEquals(Status::PASSED, $step->getStatus()); $this->assertEquals($stepTitle, $step->getTitle()); $this->assertNotEmpty($step->getStart()); $this->assertEquals($stepName, $step->getName()); $this->assertEmpty($step->getStop()); $this->assertEmpty($step->getSteps()); $this->assertEmpty($step->getAttachments()); }