/** * @return Node\Scenario */ protected function createScenario() { $feature = $this->getMockBuilder(Node\Feature::class)->getMock(); $feature->expects($this->any())->method('getId')->will($this->returnValue(static::FEATURE_ID)); $scenario = new Node\Scenario(); $scenario->setFeature($feature); return $scenario; }
/** * @param Node\Scenario $scenario * * @return array */ protected function processScenario(Node\Scenario $scenario) { $currentScenario = ['id' => $scenario->getId(), 'tags' => $scenario->getTags() ? $this->processTags($scenario->getTags()) : [], 'keyword' => $scenario->getKeyword(), 'name' => $scenario->getName(), 'line' => $scenario->getLine(), 'description' => $scenario->getDescription(), 'type' => $scenario->getType(), 'steps' => [], 'examples' => []]; if (is_array($scenario->getSteps())) { foreach ($scenario->getSteps() as $step) { array_push($currentScenario['steps'], $this->processStep($step)); } } if (is_array($scenario->getExamples())) { foreach ($scenario->getExamples() as $example) { array_push($currentScenario['examples'], $this->processExample($example)); } } return $currentScenario; }
/** * @param BehatEvent\AfterStepTested $event */ public function onAfterStepTested(BehatEvent\StepTested $event) { $this->timer->stop(); $result = $event->getTestResult(); $step = new Node\Step(); $step->setKeyword($event->getStep()->getKeyword()); $step->setName($event->getStep()->getText()); $step->setLine($event->getStep()->getLine()); $step->setArguments($event->getStep()->getArguments()); $step->setResult($result); $step->setResultCode($result->getResultCode()); $step->setDuration($this->timer->getSeconds()); $this->processStep($step, $result); $this->currentScenario->addStep($step); }