Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function isFeatureMatch(FeatureNode $feature)
 {
     if ('/' === $this->filterString[0]) {
         return (bool) preg_match($this->filterString, $feature->getTitle());
     }
     return false !== mb_strpos($feature->getTitle(), $this->filterString);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 protected function printFeatureName(FeatureNode $feature)
 {
     $this->writeln('<h2>');
     $this->writeln('<span class="keyword">' . $feature->getKeyword() . ': </span>');
     $this->writeln('<span class="title">' . $feature->getTitle() . '</span>');
     $this->writeln('</h2>');
 }
Esempio n. 3
0
 /**
  * Prints feature title using provided printer.
  *
  * @param OutputPrinter $printer
  * @param FeatureNode   $feature
  */
 private function printTitle(OutputPrinter $printer, FeatureNode $feature)
 {
     $printer->write(sprintf('%s{+keyword}%s:{-keyword}', $this->indentText, $feature->getKeyword()));
     if ($title = $feature->getTitle()) {
         $printer->write(sprintf(' %s', $title));
     }
     $printer->writeln();
 }
 public function testTitle()
 {
     $feature = new FeatureNode();
     $this->assertNull($feature->getTitle());
     $feature->setTitle('test title 1');
     $this->assertEquals('test title 1', $feature->getTitle());
     $feature = new FeatureNode('test title 2');
     $this->assertEquals('test title 2', $feature->getTitle());
 }
 /**
  * @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);
 }
Esempio n. 6
0
 public function __construct(FeatureNode $featureNode, ScenarioNode $scenarioNode, $steps = [])
 {
     $this->featureNode = $featureNode;
     $this->scenarioNode = $scenarioNode;
     $this->steps = $steps;
     $this->setMetadata(new Metadata());
     $this->scenario = new Scenario($this);
     $this->getMetadata()->setName($featureNode->getTitle());
     $this->getMetadata()->setFeature($scenarioNode->getTitle());
     $this->getMetadata()->setFilename($featureNode->getFile());
 }
 public function createFilename(FeatureNode $feature, ScenarioInterface $scenario, OutlineNode $outline = null)
 {
     $filename = Transliterator::transliterate($feature->getTitle(), $this->separator) . DIRECTORY_SEPARATOR;
     if ($outline) {
         $filename .= Transliterator::transliterate($outline->getTitle(), $this->separator) . DIRECTORY_SEPARATOR . $this->separator;
     }
     $filename .= Transliterator::transliterate($scenario->getTitle(), $this->separator);
     if ($outline) {
         $filename .= $this->separator;
     }
     return $filename;
 }
Esempio n. 8
0
 /**
  * {@inheritDoc}
  */
 public function printHeader(Formatter $formatter, FeatureNode $feature)
 {
     $stats = $this->statistics->getScenarioStatCounts();
     if (0 === count($stats)) {
         $totalCount = 0;
     } else {
         $totalCount = array_sum($stats);
     }
     /** @var JUnitOutputPrinter $outputPrinter */
     $outputPrinter = $formatter->getOutputPrinter();
     $outputPrinter->addTestsuite(array('name' => $feature->getTitle(), 'tests' => $totalCount, 'skipped' => $stats[TestResult::SKIPPED], 'failures' => $stats[TestResult::FAILED], 'errors' => $stats[TestResult::PENDING] + $stats[StepResult::UNDEFINED]));
     $this->statistics->reset();
 }
 /**
  * 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;
 }
Esempio n. 10
0
 /**
  * Prints feature header.
  *
  * @param FeatureNode $feature Current feature node
  * @return [void]
  *
  * @uses printFeatureOrScenarioTags()
  * @uses printFeatureName()
  * @uses printFeatureDescription()
  */
 protected function printFeatureHeader(FeatureNode $feature)
 {
     $this->writeln('<table style="' . $this->_getTableStyles() . '">');
     $this->writeln('<colgroup>
     <col width="287">
     <col width="121">
     <col width="157">
     <col width="77">
     <col width="288">
     </colgroup>');
     $this->writeln('<tr>
     <th colspan=5 rowspan=1 style="' . $this->_getTitleStyles() . '">
     Pantheon: ' . $feature->getTitle() . '<br>' . date('Y-m-d') . '</th>
     </tr>');
     $this->writeln('<tr>');
     $headers = array('Core Experience', 'Status', 'Errors', 'Workflow ID', 'Comments');
     foreach ($headers as $header) {
         $this->writeln('<th style="' . $this->_getHeaderStyles() . '">' . $header . '</th>');
     }
 }
Esempio n. 11
0
 /**
  * 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());
 }
Esempio n. 12
0
 /**
  * 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")];
 }
Esempio n. 13
0
 /**
  * Prints testsuite footer.
  *
  * @param   Behat\Gherkin\Node\FeatureNode  $feature
  * @param   float                           $time
  */
 protected function printTestSuiteFooter(FeatureNode $feature, $time)
 {
     $suiteStats = sprintf('errors="0" failures="%d" name="%s" tests="%d" time="%f"', count($this->exceptions), $feature->getTitle(), $this->stepsCount, $time);
     $this->writeln("<testsuite {$suiteStats}>");
     $this->writeln(implode("\n", $this->testcases));
     $this->writeln('</testsuite>');
 }
Esempio n. 14
0
 public function toString()
 {
     return $this->featureNode->getTitle() . ': ' . $this->getFeature();
 }
 /**
  * Prints testsuite footer.
  *
  * @param FeatureNode $feature
  * @param float       $time
  */
 protected function printTestSuiteFooter(FeatureNode $feature, $time)
 {
     $suiteStats = sprintf('errors="0" failures="%d" skipped="%d" name="%s" tests="%d" time="%F"', $this->exceptionsCount, $this->pendingCount, htmlspecialchars($feature->getTitle()), $this->scenariosCount, $time);
     $this->writeln("<testsuite {$suiteStats}>");
     $this->writeln(implode("\n", $this->testcases));
     $this->writeln('</testsuite>');
 }
Esempio n. 16
0
 /**
  * Prints testsuite footer.
  *
  * @param FeatureNode $feature
  * @param float       $time
  */
 protected function printTestSuiteFooter(FeatureNode $feature, $time)
 {
     $suiteStats = sprintf('classname="behat.features" errors="0" failures="%d" name="%s" file="%s" tests="%d" time="%F"', $this->exceptionsCount, htmlspecialchars($feature->getTitle()), htmlspecialchars($feature->getFile()), $this->stepsCount, $time);
     $this->writeln("<testsuite {$suiteStats}>");
     $this->writeln(implode("\n", $this->testcases));
     $this->writeln('</testsuite>');
 }
Esempio n. 17
0
 public function getTitle()
 {
     return $this->featureNode->getTitle();
 }