Beispiel #1
0
    public function testPyStringFromLinesCreation()
    {
        $string = new PyStringNode();
        $string->addLine('Hello,');
        $string->addLine('  Gherkin');
        $string->addLine('    users');
        $string->addLine('      =)');
        $this->assertEquals(<<<STRING
Hello,
  Gherkin
    users
      =)
STRING
, (string) $string);
    }
    public function testTokens()
    {
        $string = new PyStringNode();
        $string->addLine('Hello, <username>');
        $string->addLine('everything is <status>?');
        $string1 = $string->createExampleRowStepArgument(array('username' => 'John', 'status' => 'ok'));
        $this->assertNotSame($string, $string1);
        $this->assertSame(<<<STRING
Hello, John
everything is ok?
STRING
, (string) $string1);
        $string2 = $string->createExampleRowStepArgument(array('username' => 'Mike', 'status' => 'bad'));
        $this->assertNotSame($string, $string2);
        $this->assertSame(<<<STRING
Hello, Mike
everything is bad?
STRING
, (string) $string2);
    }
Beispiel #3
0
 /**
  * Parses PyString token & returns it's node.
  *
  * @return  Behat\Gherkin\Node\PyStringNode
  */
 protected function parsePyString()
 {
     $token = $this->expectTokenType('PyStringOperator');
     $node = new Node\PyStringNode();
     while ('PyStringOperator' !== ($predicted = $this->predictTokenType()) && 'Text' === $predicted) {
         $node->addLine($this->parseText(false));
     }
     $this->expectTokenType('PyStringOperator');
     $this->skipExtraChars();
     return $node;
 }