Пример #1
0
 public function testArguments()
 {
     $step = new StepNode('Given', null);
     $this->assertEquals(0, count($step->getArguments()));
     $this->assertFalse($step->hasArguments());
     $step->addArgument(new PyStringNode());
     $this->assertEquals(1, count($step->getArguments()));
     $this->assertTrue($step->hasArguments());
     $step->addArgument(new TableNode());
     $this->assertEquals(2, count($step->getArguments()));
     $this->assertTrue($step->hasArguments());
     $arguments = $step->getArguments();
     $this->assertInstanceOf('Behat\\Gherkin\\Node\\PyStringNode', $arguments[0]);
     $this->assertInstanceOf('Behat\\Gherkin\\Node\\TableNode', $arguments[1]);
 }
Пример #2
0
 /**
  * Loads step from provided hash.
  *
  * @param array   $hash Step hash
  * @param integer $line Step definition line
  *
  * @return StepNode
  */
 protected function loadStepHash(array $hash, $line = 0)
 {
     $step = new Node\StepNode($hash['type'], isset($hash['text']) ? $hash['text'] : null, isset($hash['line']) ? $hash['line'] : $line);
     if (isset($hash['arguments'])) {
         foreach ($hash['arguments'] as $argumentHash) {
             if ('table' === $argumentHash['type']) {
                 $step->addArgument($this->loadTableHash($argumentHash['rows']));
             } elseif ('pystring' === $argumentHash['type']) {
                 $step->addArgument($this->loadPyStringHash($argumentHash));
             }
         }
     }
     return $step;
 }
Пример #3
0
 /**
  * Parses step token & returns it's node.
  *
  * @return  Behat\Gherkin\Node\StepNode
  */
 protected function parseStep()
 {
     $token = $this->expectTokenType('Step');
     $node = new Node\StepNode($token->value, trim($token->text) ?: null, $token->line);
     $this->skipExtraChars();
     // Parse PyString argument
     if ('PyStringOperator' === $this->predictTokenType()) {
         $node->addArgument($this->parseExpression());
     }
     // Parse Table argument
     if ('TableRow' === $this->predictTokenType()) {
         $node->addArgument($this->parseExpression());
     }
     return $node;
 }