3c66681d463b73a270c88245393ac3f7c9ceee4b
[lhc/web/wiklou.git] / tests / SanitizerTest.php
1 <?php
2
3 class SanitizerTest extends PHPUnit_Framework_TestCase {
4 function testDecodeNamed() {
5 $this->assertEquals(
6 "\xc3\xa9cole",
7 Sanitizer::decodeCharReferences( '&eacute;cole' ) );
8 }
9
10 function testDecodeNumbered() {
11 $this->assertEquals(
12 "\xc4\x88io bonas dans l'\xc3\xa9cole!",
13 Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&#233;cole!" ) );
14 }
15
16 function testDecodeMixed() {
17 $this->assertEquals(
18 "\xc4\x88io bonas dans l'\xc3\xa9cole!",
19 Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&eacute;cole!" ) );
20 }
21
22 function testDecodeMixedComplex() {
23 $this->assertEquals(
24 "\xc4\x88io bonas dans l'\xc3\xa9cole! (mais pas &#x108;io dans l'&eacute;cole)",
25 Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&eacute;cole! (mais pas &amp;#x108;io dans l'&#38;eacute;cole)" ) );
26 }
27
28 function testDecodeInvalidAmp() {
29 $this->assertEquals(
30 "a & b",
31 Sanitizer::decodeCharReferences( "a & b" ) );
32 }
33
34 function testDecodeInvalidNamed() {
35 $this->assertEquals(
36 "&foo;",
37 Sanitizer::decodeCharReferences( "&foo;" ) );
38 }
39
40 function testDecodeInvalidNumbered() {
41 $this->assertEquals(
42 UTF8_REPLACEMENT,
43 Sanitizer::decodeCharReferences( "&#88888888888888;" ) );
44 }
45
46 /* TODO: many more! */
47 }
48
49