def test_unicode(self):
     self.assertEquals(
         'ni\xf1o',
         template_remover.clean_php('ni\xf1o')
     )
     self.assertEquals(
         '\xe9',
         template_remover.clean_php('\xe9')
     )
Esempio n. 2
0
 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))
Esempio n. 5
0
    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')
Esempio n. 7
0
 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>')
     )
Esempio n. 10
0
 def test_spaces_are_preserved(self):
     self.assertEquals('  \t\n    ',
                       template_remover.clean_php('  \t\n    '))
Esempio n. 11
0
 def test_clean_php_control_multiline(self):
     self.assertEquals(
         '\n\n',
         template_remover.clean_php(
             '  <?php if ($a > 1) {    \n echo "foo"\n  } ?>'))
Esempio n. 12
0
 def test_clean_php_short_tags(self):
     self.assertEquals('a       b', template_remover.clean_php('a <? ?> b'))
Esempio n. 13
0
 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 } ?>'))
Esempio n. 14
0
 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>'))
Esempio n. 15
0
 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_inline_echho_not_closed(self):
     with self.assertRaises(AssertionError):
         template_remover.clean_php('<a href="<?= $foo \n')
 def test_clean_php_short_echo(self):
     self.assertEquals(
         '<a href="0000000000000000">Link</a>',
         template_remover.clean_php('<a href="<? echo $foo; ?>">Link</a>')
     )
Esempio n. 18
0
 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 } ?>')
     )
Esempio n. 20
0
 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    ')
     )
Esempio n. 24
0
 def test_clean_php_open_tag_at_eof(self):
     with self.assertRaises(AssertionError):
         template_remover.clean_php('<?php')