3 class SanitizerTest
extends PHPUnit_Framework_TestCase
{
6 AutoLoader
::loadClass( 'Sanitizer' );
9 function testDecodeNamedEntities() {
12 Sanitizer
::decodeCharReferences( 'école' ),
13 'decode named entities'
17 function testDecodeNumericEntities() {
19 "\xc4\x88io bonas dans l'\xc3\xa9cole!",
20 Sanitizer
::decodeCharReferences( "Ĉio bonas dans l'école!" ),
21 'decode numeric entities'
25 function testDecodeMixedEntities() {
27 "\xc4\x88io bonas dans l'\xc3\xa9cole!",
28 Sanitizer
::decodeCharReferences( "Ĉio bonas dans l'école!" ),
29 'decode mixed numeric/named entities'
33 function testDecodeMixedComplexEntities() {
35 "\xc4\x88io bonas dans l'\xc3\xa9cole! (mais pas Ĉio dans l'école)",
36 Sanitizer
::decodeCharReferences(
37 "Ĉio bonas dans l'école! (mais pas Ĉio dans l'école)"
39 'decode mixed complex entities'
43 function testInvalidAmpersand() {
46 Sanitizer
::decodeCharReferences( 'a & b' ),
51 function testInvalidEntities() {
54 Sanitizer
::decodeCharReferences( '&foo;' ),
55 'Invalid named entity'
59 function testInvalidNumberedEntities() {
60 $this->assertEquals( UTF8_REPLACEMENT
, Sanitizer
::decodeCharReferences( "�" ), 'Invalid numbered entity' );
63 function testSelfClosingTag() {
64 $GLOBALS['wgUseTidy'] = false;
66 '<div>Hello world</div>',
67 Sanitizer
::removeHTMLtags( '<div>Hello world</div />' ),
68 'Self-closing closing div'