public function testLine() { $step = new StepNode('Given'); $this->assertEquals(0, $step->getLine()); $step = new StepNode('Given', null, 23); $this->assertEquals(23, $step->getLine()); }
/** * Changes step node type for types But, And to type of previous step if it exists else sets to Given * * @param StepNode $node * @param StepNode[] $steps * @return StepNode */ private function normalizeStepNodeKeywordType(StepNode $node, array $steps = array()) { if (in_array($node->getKeywordType(), array('And', 'But'))) { if ($prev = end($steps)) { $keywordType = $prev->getKeywordType(); } else { $keywordType = 'Given'; } $node = new StepNode($node->getKeyword(), $node->getText(), $node->getArguments(), $node->getLine(), $keywordType); } return $node; }
/** * @param FeatureNode $featureNode * @param StepNode $stepNode * @return ScenarioInterface|null */ private function detectScenario(FeatureNode $featureNode, StepNode $stepNode) { foreach ($featureNode->getScenarios() as $scenario) { foreach ($scenario->getSteps() as $step) { if ($step->getLine() === $stepNode->getLine() && $step->getText() === $stepNode->getText()) { return $scenario; } } } return null; }
/** * add results for step tests * @param FeatureNode $feature object * @param ScenarioInterface $scenario object * @param StepNode $step object * @param TestResult $testResult object * @return null */ public function addStepResult(FeatureNode $feature, ScenarioInterface $scenario, StepNode $step, TestResult $testResult) { $featurePath = $feature->getFile(); $scenarioLine = $scenario->getLine(); $this->testResults[$featurePath]["scenarios"][$scenarioLine]["steps"][$step->getLine()] = ["name" => $step->getText(), "line" => $step->getLine(), "testResultCode" => $testResult->getResultCode(), "testResult" => self::RESULT_CODES_MAPPING[$testResult->getResultCode()]]; }