Ejemplo n.º 1
0
 /**
  * tests getTokensUntilClosingScope
  */
 public function testGetTokensUntilClosingScope()
 {
     $lexer = new Lexer("{ foo => 'bar' \n { next => 'level' } }");
     $parser = new Parser_Dummy($lexer->tokens());
     $this->assertEquals(9, count($parser->getTokensUntilClosingScope()));
     // also check of the parser is done
     $this->assertTrue($parser->parserIsDone());
     // include the scope
     $lexer = new Lexer("{ foo => 'bar' \n { next => 'level' } } '123'");
     $parser = new Parser_Dummy($lexer->tokens());
     $this->assertEquals(11, count($parser->getTokensUntilClosingScope(true)));
     // parser should not be done
     $this->assertFalse($parser->parserIsDone());
     // validate the current token
     $this->assertEquals('123', $parser->currentToken()->getValue());
 }
Ejemplo n.º 2
0
 /**
  * tests Lexer error
  *
  * @expectedException \Tattoo\Lexer\Exception
  */
 public function test_unknownToken()
 {
     $lexer = new Lexer("ç");
     $lexer->tokens();
 }
Ejemplo n.º 3
0
 /**
  * tests Parser
  */
 public function testConsturct()
 {
     $lexer = new Lexer('foo');
     $parser = new Scope($lexer->tokens());
     $this->assertInstanceOf('Tattoo\\Parser', $parser);
 }
Ejemplo n.º 4
0
 /**
  * Parse tattoo code
  *
  * @throws Tattoo\Exception
  *
  * @param string            $code
  * @return Node\Scope
  */
 public function parse($code)
 {
     $lexer = new Lexer($code);
     $parser = new ScopeParser($lexer->tokens());
     return $parser->parse();
 }
Ejemplo n.º 5
0
 /**
  * parse attributes string and assert the results
  */
 protected function assertAttributesArray(array $expected, $code)
 {
     $lexer = new Lexer($code);
     $parser = new ShortTagParser($lexer->tokens());
     foreach ($parser->parseAttributeTokens($parser->getTokens()) as $key => $values) {
         $this->assertEquals($expected[$key], $values);
     }
 }