Skip to content

Commit

Permalink
MDL-32109 migrate tests to PHPUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Mar 24, 2012
1 parent 986f8ea commit 3f0fe2b
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions lib/tests/htmlpurifier_test.php
Expand Up @@ -189,5 +189,63 @@ public function test_cleaning_nastiness() {
$text = 'x<form></form>x';
$this->assertSame('xx', purify_html($text));
}

/**
* Test internal function used for clean_text() speedup.
* @return void
*/
function test_is_purify_html_necessary() {
// first our shortcuts
$text = "";
$this->assertFalse(is_purify_html_necessary($text));
$this->assertSame($text, purify_html($text));

$text = "666";
$this->assertFalse(is_purify_html_necessary($text));
$this->assertSame($text, purify_html($text));

$text = "abc\ndef \" ' ";
$this->assertFalse(is_purify_html_necessary($text));
$this->assertSame($text, purify_html($text));

$text = "abc\n<p>def</p>efg<p>hij</p>";
$this->assertFalse(is_purify_html_necessary($text));
$this->assertSame($text, purify_html($text));

$text = "<br />abc\n<p>def<em>efg</em><strong>hi<br />j</strong></p>";
$this->assertFalse(is_purify_html_necessary($text));
$this->assertSame($text, purify_html($text));

// now failures
$text = "&nbsp;";
$this->assertTrue(is_purify_html_necessary($text));

$text = "Gin & Tonic";
$this->assertTrue(is_purify_html_necessary($text));

$text = "Gin > Tonic";
$this->assertTrue(is_purify_html_necessary($text));

$text = "Gin < Tonic";
$this->assertTrue(is_purify_html_necessary($text));

$text = "<div>abc</div>";
$this->assertTrue(is_purify_html_necessary($text));

$text = "<span>abc</span>";
$this->assertTrue(is_purify_html_necessary($text));

$text = "<br>abc";
$this->assertTrue(is_purify_html_necessary($text));

$text = "<p class='xxx'>abc</p>";
$this->assertTrue(is_purify_html_necessary($text));

$text = "<p>abc<em></p></em>";
$this->assertTrue(is_purify_html_necessary($text));

$text = "<p>abc";
$this->assertTrue(is_purify_html_necessary($text));
}
}

0 comments on commit 3f0fe2b

Please sign in to comment.