protected function getParser()
 {
     $parser = new TestParser(new Twig_Environment($this->getMock('Twig_LoaderInterface')));
     $parser->setParent(new Twig_Node());
     $parser->stream = $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock();
     return $parser;
 }
Example #2
0
 /**
  * testParseArrayCamelCased
  *
  * Mobile team send us files with camel cased keys - on some project. So butcher them
  *
  * @return void
  */
 public function testParseArrayCamelCased()
 {
     $data = array('camelCasedKey' => 'bar');
     $settings = array('locale' => 'en', 'domain' => 'default', 'category' => 'LC_MESSAGES');
     $expected = array('count' => 1, 'translations' => array(array('locale' => 'en', 'domain' => 'default', 'category' => 'LC_MESSAGES', 'key' => 'camel.cased.key', 'value' => 'bar')));
     $result = TestParser::parseArray($data, $settings);
     $this->assertSame($expected, $result, 'camel cased keys are expected to be converted to dot delimited');
 }
Example #3
0
 public function testPartialQueryKeys()
 {
     $parser = new TestParser(array('q' => 'condition'));
     $this->assertTrue($parser->isSupportedHttpQueryKey('q'));
     $this->assertEquals('condition', $parser->getClauseForHttpQueryKey('q'));
     $parser->removeHttpQueryKey('q');
     $this->assertFalse($parser->isSupportedHttpQueryKey('q'));
     $parser->setClauseForHttpQueryKey('o', 'order');
     $this->assertTrue($parser->isSupportedHttpQueryKey('o'));
 }
Example #4
0
 protected function getParser()
 {
     $parser = new TestParser(new Twig_Environment($this->getMockBuilder('Twig_LoaderInterface')->getMock()));
     $parser->setParent(new Twig_Node());
     $parser->stream = $this->getMockBuilder('Twig_TokenStream')->disableOriginalConstructor()->getMock();
     $parser->stream->expects($this->any())->method('getSourceContext')->will($this->returnValue(new Twig_Source('', '')));
     return $parser;
 }
    {
        if (trim($data)) {
            println($data);
        }
    }
    function process_testpi($data)
    {
        printfln('Processing instruction testpi: %s', $data);
    }
    function unknown_endtag($name)
    {
        println('end: ' . $name);
    }
    function handle_comment($data)
    {
        println($data);
    }
}
$data = '<?xml version="1.0"?>
<div>
	<p>test</p>
	<p>Some more <b>testing</b></p>
	<?testpi This is a processing instruction ?>
	<!-- This is a
	comment -->
	<p>Finally, some more testing.</p>
	Heh.
</div>';
$p = new TestParser();
$p->feed($data);
$p->close();