コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
ファイル: Gherkin.php プロジェクト: neronmoon/Codeception
 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);
     }
 }
コード例 #3
0
 /**
  * {@inheritdoc}
  */
 public function test(Environment $env, FeatureNode $feature, $skip)
 {
     $background = $feature->getBackground();
     if (null === $background) {
         throw new FeatureHasNoBackgroundException(sprintf('Feature `%s` has no background that could be tested.', $feature->getFile()), $feature);
     }
     $results = $this->containerTester->test($env, $feature, $background, $skip);
     return new TestResults($results);
 }
コード例 #4
0
 /**
  * {@inheritdoc}
  */
 public function tearDown(Environment $env, FeatureNode $feature, $skip, TestResult $result)
 {
     $event = new BeforeBackgroundTeardown($env, $feature, $feature->getBackground(), $result);
     $this->eventDispatcher->dispatch(BackgroundTested::BEFORE_TEARDOWN, $event);
     $teardown = $this->baseTester->tearDown($env, $feature, $skip, $result);
     $event = new AfterBackgroundTested($env, $feature, $feature->getBackground(), $result, $teardown);
     $this->eventDispatcher->dispatch(BackgroundTested::AFTER, $event);
     return $teardown;
 }
コード例 #5
0
 public function testBackground()
 {
     $feature = new FeatureNode();
     $this->assertNull($feature->getBackground());
     $this->assertFalse($feature->hasBackground());
     $feature->setBackground($background = new BackgroundNode());
     $this->assertSame($feature, $feature->getBackground()->getFeature());
     $this->assertSame($background, $feature->getBackground());
     $this->assertTrue($feature->hasBackground());
 }
コード例 #6
0
ファイル: LineRangeFilter.php プロジェクト: higrow/Gherkin
 /**
  * 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());
 }
コード例 #7
0
ファイル: Gherkin.php プロジェクト: charlycoste/BDDWizard
 public function getBackground()
 {
     return $this->featureNode->getBackground();
 }