diff --git a/tests/phpunit/tests/general/allowedTags.php b/tests/phpunit/tests/general/allowedTags.php new file mode 100644 index 0000000000000..47c415d5e79c4 --- /dev/null +++ b/tests/phpunit/tests/general/allowedTags.php @@ -0,0 +1,75 @@ +original_allowedtags = $allowedtags; + } + + public function tear_down() { + global $allowedtags; + $allowedtags = $this->original_allowedtags; + parent::tear_down(); + } + + /** + * Tests that allowed_tags() returns encoded string of default allowed tags. + * + * @ticket 65819 + */ + public function test_allowed_tags_default() { + $expected = '<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> '; + $this->assertSame( $expected, allowed_tags() ); + } + + /** + * Tests that allowed_tags() formats custom tags and attributes correctly. + * + * @ticket 65819 + */ + public function test_allowed_tags_custom() { + global $allowedtags; + + $allowedtags = array( + 'em' => array(), + 'strong' => array( 'class' => true ), + 'span' => array( + 'class' => true, + 'id' => true, + ), + ); + + $expected = '<em> <strong class=""> <span class="" id=""> '; + $this->assertSame( $expected, allowed_tags() ); + } + + /** + * Tests that allowed_tags() returns an empty string when allowedtags is empty. + * + * @ticket 65819 + */ + public function test_allowed_tags_empty() { + global $allowedtags; + + $allowedtags = array(); + + $this->assertSame( '', allowed_tags() ); + } +}