/**
  * Defines a step with ->Given|When|Then|...('/regex/', callback) or
  * call a step with ->Given|When|Then|...('I enter "12" in the field', $world) or
  * even with arguments ->Given|When|Then|...('I fill up fields', $world, $table).
  *
  * @param   string  $type       step type (Given|When|Then|...)
  * @param   string  $arguments  step regex & callback
  *
  * @throws  Behat\Behat\Exception\RedundantException     if step definition is already exists
  */
 public function __call($type, $arguments)
 {
     if (2 == count($arguments) && is_callable($arguments[1])) {
         switch (strtolower($type)) {
             case 'when':
                 $definition = new When($arguments[1], $arguments[0]);
                 break;
             case 'then':
                 $definition = new Then($arguments[1], $arguments[0]);
                 break;
             case 'given':
             default:
                 $definition = new Given($arguments[1], $arguments[0]);
                 break;
         }
         $this->dispatcher->addDefinition($definition);
     } else {
         $text = array_shift($arguments);
         $world = array_shift($arguments);
         $step = new StepNode($type, $text);
         $step->setArguments($arguments);
         $definition = $this->dispatcher->findDefinition($world, $step);
         $definition->run($world);
     }
     return $this;
 }
Exemple #2
0
 /**
  * Defines a step with ->Given|When|Then|...('/regex/', callback) or
  * call a step with ->Given|When|Then|...('I enter "12" in the field', $world) or
  * even with arguments ->Given|When|Then|...('I fill up fields', $world, $table).
  *
  * @param   string  $type       step type (Given|When|Then|...)
  * @param   string  $arguments  step regex & callback
  *
  * @throws  Behat\Behat\Exception\Redundant     if step definition is already exists
  */
 public function __call($type, $arguments)
 {
     if (2 == count($arguments) && is_callable($arguments[1])) {
         $debug = debug_backtrace();
         $debug = $debug[1];
         $this->objects[] = new Definition($type, $arguments[0], $arguments[1], $debug['file'], $debug['line']);
     } else {
         $text = array_shift($arguments);
         $world = array_shift($arguments);
         $step = new StepNode($type, $text);
         $step->setArguments($arguments);
         $definition = $this->dispatcher->findDefinition($step);
         $definition->run($world);
     }
     return $this;
 }