From b37954110d2184279a7f400d8750996a27b8f666 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Wed, 5 Feb 2014 20:18:51 +0100 Subject: Bring back unit tests (they should be removed when creating a package) --- tests/Framework/Washtml.php | 127 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 tests/Framework/Washtml.php (limited to 'tests/Framework/Washtml.php') diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php new file mode 100644 index 000000000..7485d4383 --- /dev/null +++ b/tests/Framework/Washtml.php @@ -0,0 +1,127 @@ +Firefox' + .'Internet Explorer

'; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertNotRegExp('/data:text/', $washed, "Remove data:text/html links"); + $this->assertNotRegExp('/vbscript:/', $washed, "Remove vbscript: links"); + } + + /** + * Test fixing of invalid href (#1488940) + */ + function test_href() + { + $html = "

Firefox"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertRegExp('|href="http://test.com">|', $washed, "Link href with newlines (#1488940)"); + } + + /** + * Test handling HTML comments + */ + function test_comments() + { + $washer = new rcube_washtml; + + $html = "

p2

"; + $washed = $washer->wash($html); + + $this->assertEquals('

p2

', $washed, "HTML conditional comments (#1489004)"); + + $html = "

test

', $washed, "HTML invalid comments (#1487759)"); + } + + /** + * Test fixing of invalid self-closing elements (#1489137) + */ + function test_self_closing() + { + $html = "|', $washed, "Self-closing textarea (#1489137)"); + } + + /** + * Test fixing of invalid closing tags (#1489446) + */ + function test_closing_tag_attrs() + { + $html = "test"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertRegExp('||', $washed, "Invalid closing tag (#1489446)"); + } + + /** + * Test fixing of invalid lists nesting (#1488768) + */ + function test_lists() + { + $data = array( + array( + "
  1. First
  2. Second
  3. Third
", + "
  1. First
  2. Second
    • First sub
  3. Third
" + ), + array( + "
  1. First
    • First sub
", + "
  1. First
    • First sub
", + ), + array( + "
  1. First
    1. First sub
", + "
  1. First
    1. First sub
", + ), + array( + "", + "", + ), + array( + "", + "", + ), + array( + "
    ", + "
      ", + ), + array( + "
        ", + "
          ", + ), + ); + + foreach ($data as $element) { + rcube_washtml::fix_broken_lists($element[0]); + + $this->assertSame($element[1], $element[0], "Broken nested lists (#1488768)"); + } + } + +} -- cgit v1.2.3