mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 04:52:36 +02:00
MDL-32109 migrate tests to PHPUnit
This commit is contained in:
parent
986f8ea285
commit
3f0fe2b820
@ -189,5 +189,63 @@ class core_htmlpurifier_testcase extends basic_testcase {
|
||||
$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 = " ";
|
||||
$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));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user