Example #1
0
 /**
  * Visits & tests BackgroundNode.
  *
  * @param   Behat\Gherkin\Node\AbstractNode $background
  *
  * @return  integer
  */
 public function visit(AbstractNode $background)
 {
     $this->dispatcher->dispatch('beforeBackground', new BackgroundEvent($background));
     $result = 0;
     $skip = false;
     // Visit & test steps
     foreach ($background->getSteps() as $step) {
         $tester = $this->container->get('behat.tester.step');
         $tester->setEnvironment($this->environment);
         $tester->skip($skip);
         $stResult = $step->accept($tester);
         if (0 !== $stResult) {
             $skip = true;
         }
         $result = max($result, $stResult);
     }
     $this->dispatcher->dispatch('afterBackground', new BackgroundEvent($background, $result, $skip));
     return $result;
 }
Example #2
0
 /**
  * Visits & tests ScenarioNode.
  *
  * @param   Behat\Gherkin\Node\AbstractNode $scenario
  *
  * @return  integer
  */
 public function visit(AbstractNode $scenario)
 {
     $this->dispatcher->dispatch('beforeScenario', new ScenarioEvent($scenario, $this->environment));
     $result = 0;
     $skip = false;
     // Visit & test background if has one
     if ($scenario->getFeature()->hasBackground()) {
         $bgResult = $this->visitBackground($scenario->getFeature()->getBackground(), $this->environment);
         if (0 !== $bgResult) {
             $skip = true;
         }
         $result = max($result, $bgResult);
     }
     // Visit & test steps
     foreach ($scenario->getSteps() as $step) {
         $stResult = $this->visitStep($step, $this->environment, array(), $skip);
         if (0 !== $stResult) {
             $skip = true;
         }
         $result = max($result, $stResult);
     }
     $this->dispatcher->dispatch('afterScenario', new ScenarioEvent($scenario, $this->environment, $result, $skip));
     return $result;
 }