Example #1
0
 /**
  * Visits & tests StepNode.
  *
  * @param   Behat\Gherkin\Node\AbstractNode $step
  *
  * @return  integer
  */
 public function visit(AbstractNode $step)
 {
     $step->setTokens($this->tokens);
     $this->dispatcher->dispatch('beforeStep', new StepEvent($step, $this->environment));
     $result = 0;
     $definition = null;
     $exception = null;
     $snippet = null;
     // Find proper definition
     try {
         $definition = $this->definitions->findDefinition($step);
     } catch (Ambiguous $e) {
         $result = StepEvent::FAILED;
         $exception = $e;
     } catch (Undefined $e) {
         $result = StepEvent::UNDEFINED;
         $snippet = $this->definitions->proposeDefinition($step);
     }
     // Run test
     if (0 === $result) {
         if (!$this->skip) {
             try {
                 $definition->run($this->environment, $this->tokens);
                 $result = StepEvent::PASSED;
             } catch (Pending $e) {
                 $result = StepEvent::PENDING;
                 $exception = $e;
             } catch (\Exception $e) {
                 $result = StepEvent::FAILED;
                 $exception = $e;
             }
         } else {
             $result = StepEvent::SKIPPED;
         }
     }
     $this->dispatcher->dispatch('afterStep', new StepEvent($step, $this->environment, $result, $definition, $exception, $snippet));
     return $result;
 }
Example #2
0
 /**
  * Visits & tests StepNode.
  *
  * @param   Behat\Gherkin\Node\AbstractNode $step
  *
  * @return  integer
  */
 public function visit(AbstractNode $step)
 {
     $step->setTokens($this->tokens);
     $this->dispatcher->dispatch('beforeStep', new StepEvent($step, $this->context));
     $afterEvent = $this->executeStep($step);
     $this->dispatcher->dispatch('afterStep', $afterEvent);
     return $afterEvent->getResult();
 }