def test_unicode(self): self.assertEquals( 'ni\xf1o', template_remover.clean_php('ni\xf1o') ) self.assertEquals( '\xe9', template_remover.clean_php('\xe9') )
def test_clean_php_multiline(self): self.assertEquals( ' <a href="#next">Next</a>\n' + '<a href="00000000000">Link</a>', template_remover.clean_php( '<?php if ($a > 1) { ?><a href="#next">Next</a><?php } ?>\n' + '<a href="<?= $foo ?>">Link</a>'))
def test_clean_php_multiline(self): self.assertEquals( ' <a href="#next">Next</a>\n' + '<a href="00000000000">Link</a>', template_remover.clean_php( '<?php if ($a > 1) { ?><a href="#next">Next</a><?php } ?>\n' + '<a href="<?= $foo ?>">Link</a>') )
def test_php_comprehensive(self): template = '''<html> <body> <?php if($foo) { ?> <a href="<?= $foo ?>"><a> <?php } ?> <!-- comment -> ''' expected = '''<html> <body> <a href="00000000000"><a> <!-- comment -> ''' self.assertEquals(expected, template_remover.clean_php(template))
def test_clean_php_open_tag_at_eof(self): with self.assertRaises(AssertionError): template_remover.clean_php('<?php')
def test_clean_php_inline_echho_not_closed(self): with self.assertRaises(AssertionError): template_remover.clean_php('<a href="<?= $foo \n')
def test_clean_php_short_tags(self): self.assertEquals( 'a b', template_remover.clean_php('a <? ?> b') )
def test_clean_php_inline_echo_mixed(self): self.assertEquals( ' <a href="00000000000">Link</a>', template_remover.clean_php( ' <?php ?><a href="<?= $foo ?>">Link</a>') )
def test_spaces_are_preserved(self): self.assertEquals(' \t\n ', template_remover.clean_php(' \t\n '))
def test_clean_php_control_multiline(self): self.assertEquals( '\n\n', template_remover.clean_php( ' <?php if ($a > 1) { \n echo "foo"\n } ?>'))
def test_clean_php_short_tags(self): self.assertEquals('a b', template_remover.clean_php('a <? ?> b'))
def test_clean_php_control(self): self.assertEquals( ' <a href="#next">Next</a>', template_remover.clean_php( '<?php if ($a > 1) { ?><a href="#next">Next</a><?php } ?>'))
def test_clean_php_inline_echo_mixed(self): self.assertEquals( ' <a href="00000000000">Link</a>', template_remover.clean_php( ' <?php ?><a href="<?= $foo ?>">Link</a>'))
def test_clean_php_short_echo(self): self.assertEquals( '<a href="0000000000000000">Link</a>', template_remover.clean_php('<a href="<? echo $foo; ?>">Link</a>'))
def test_clean_php_short_echo(self): self.assertEquals( '<a href="0000000000000000">Link</a>', template_remover.clean_php('<a href="<? echo $foo; ?>">Link</a>') )
def test_php_control_at_end(self): self.assertEquals( ' placeholder ', template_remover.clean_php(' <?php ?> placeholder '))
def test_clean_php_control(self): self.assertEquals( ' <a href="#next">Next</a>', template_remover.clean_php( '<?php if ($a > 1) { ?><a href="#next">Next</a><?php } ?>') )
def test_unicode(self): self.assertEquals('ni\xf1o', template_remover.clean_php('ni\xf1o')) self.assertEquals('\xe9', template_remover.clean_php('\xe9'))
def test_clean_php_control_multiline(self): self.assertEquals( '\n\n', template_remover.clean_php( ' <?php if ($a > 1) { \n echo "foo"\n } ?>') )
def test_php_control_at_end(self): self.assertEquals( ' placeholder ', template_remover.clean_php(' <?php ?> placeholder ') )
def test_spaces_are_preserved(self): self.assertEquals( ' \t\n ', template_remover.clean_php(' \t\n ') )