public function test() { $this->makeContexts(); $description = explode("\n", $this->featureNode->getDescription()); foreach ($description as $line) { $this->getScenario()->runStep(new Comment($line)); } if ($background = $this->featureNode->getBackground()) { foreach ($background->getSteps() as $step) { $this->runStep($step); } } foreach ($this->scenarioNode->getSteps() as $step) { $this->runStep($step); } }
public function testDescription() { $feature = new FeatureNode(); $this->assertNull($feature->getDescription()); $feature->setDescription('test description 1'); $this->assertEquals('test description 1', $feature->getDescription()); $feature = new FeatureNode(null, 'test description 2'); $this->assertEquals('test description 2', $feature->getDescription()); }
/** * @param FeatureNode $feature * * @return string */ public function format(FeatureNode $feature) { $shortDesc = $feature->getKeyword() . ': ' . $feature->getTitle() . "\n"; if (!$feature->hasDescription()) { return rtrim($shortDesc); } $longDesc = implode(array_map(function ($descriptionLine) { return $this->indent() . trim($descriptionLine) . "\n"; }, explode("\n", $feature->getDescription()))); return $shortDesc . rtrim($longDesc); }
/** * Dumps feature. * * @param FeatureNode $feature Feature instance * * @return string */ public function dumpFeature(FeatureNode $feature) { $language = $feature->getLanguage(); $this->keywords->setLanguage($language); $content = '' . $this->dumpLanguage($language) . ($feature->getTags() ? PHP_EOL . $this->dumpTags($feature->getTags(), 0) : '') . PHP_EOL . $this->dumpKeyword($this->keywords->getFeatureKeywords(), $feature->getTitle(), 0) . PHP_EOL . $this->dumpText($feature->getDescription(), 1); if ($feature->getBackground()) { $content .= $this->dumpBackground($feature->getBackground()); } $scenarios = $feature->getScenarios(); foreach ($scenarios as $scenario) { $content .= PHP_EOL . $this->dumpScenario($scenario); } return $content; }
/** * Prints feature description. * * @param FeatureNode $feature */ protected function printFeatureDescription(FeatureNode $feature) { $lines = explode("\n", $feature->getDescription()); foreach ($lines as $line) { $this->writeln(" {$line}"); } }
/** * {@inheritdoc} */ protected function printFeatureDescription(FeatureNode $feature) { $lines = explode("\n", $feature->getDescription()); $this->writeln('<p>'); foreach ($lines as $line) { $this->writeln(htmlspecialchars($line) . "<br />"); } $this->writeln('</p>'); }
/** * Checks if Feature matches specified filter. * * @param FeatureNode $feature Feature instance * * @return Boolean */ public function isFeatureMatch(FeatureNode $feature) { return 1 === preg_match($this->pattern, $feature->getDescription()); }
/** * Filters feature according to the filter. * * @param FeatureNode $feature * * @return FeatureNode */ public function filterFeature(FeatureNode $feature) { $scenarios = array(); foreach ($feature->getScenarios() as $scenario) { if (!$this->isScenarioMatch($scenario)) { continue; } if ($scenario instanceof OutlineNode && $scenario->hasExamples()) { $table = $scenario->getExampleTable()->getTable(); $lines = array_keys($table); $filteredTable = array($lines[0] => $table[$lines[0]]); unset($table[$lines[0]]); foreach ($table as $line => $row) { if ($this->filterMinLine <= $line && $this->filterMaxLine >= $line) { $filteredTable[$line] = $row; } } $scenario = new OutlineNode($scenario->getTitle(), $scenario->getTags(), $scenario->getSteps(), new ExampleTableNode($filteredTable, $scenario->getExampleTable()->getKeyword()), $scenario->getKeyword(), $scenario->getLine()); } $scenarios[] = $scenario; } return new FeatureNode($feature->getTitle(), $feature->getDescription(), $feature->getTags(), $feature->getBackground(), $scenarios, $feature->getKeyword(), $feature->getLanguage(), $feature->getFile(), $feature->getLine()); }
/** * add testResults about running feature * * @param FeatureNode $feature [description] * * @return null */ public function addFeature(FeatureNode $feature) { $featurePath = $feature->getFile(); $this->testResults[$featurePath] = ["testResultCode" => TestResult::PASSED, "testResult" => self::RESULT_CODES_MAPPING[TestResult::PASSED], "scenarios" => [], "description" => $feature->getDescription(), "title" => $feature->getTitle(), "filename" => basename($feature->getFile(), ".feature")]; }
/** * Prints feature description using provided printer. * * @param OutputPrinter $printer * @param FeatureNode $feature */ private function printDescription(OutputPrinter $printer, FeatureNode $feature) { if (!$feature->getDescription()) { $printer->writeln(); return; } foreach (explode("\n", $feature->getDescription()) as $descriptionLine) { $printer->writeln(sprintf('%s%s', $this->subIndentText, $descriptionLine)); } $printer->writeln(); }
public function getDescription() { return $this->featureNode->getDescription(); }