summaryrefslogtreecommitdiff
path: root/tests/SanitizerTest.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2006-10-11 18:12:39 +0000
committerPierre Schmitz <pierre@archlinux.de>2006-10-11 18:12:39 +0000
commit183851b06bd6c52f3cae5375f433da720d410447 (patch)
treea477257decbf3360127f6739c2f9d0ec57a03d39 /tests/SanitizerTest.php
MediaWiki 1.7.1 wiederhergestellt
Diffstat (limited to 'tests/SanitizerTest.php')
-rw-r--r--tests/SanitizerTest.php65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/SanitizerTest.php b/tests/SanitizerTest.php
new file mode 100644
index 00000000..5babf0ae
--- /dev/null
+++ b/tests/SanitizerTest.php
@@ -0,0 +1,65 @@
+<?php
+
+require_once( 'PHPUnit.php' );
+require_once( '../includes/Defines.php' );
+require_once( '../includes/Profiling.php' );
+require_once( '../includes/GlobalFunctions.php' );
+require_once( '../includes/Sanitizer.php' );
+
+class SanitizerTest extends PHPUnit_TestCase {
+ function SanitizerTest( $name ) {
+ $this->PHPUnit_TestCase( $name );
+ }
+
+ function setUp() {
+ }
+
+ function tearDown() {
+ }
+
+ function testDecodeNamed() {
+ $this->assertEquals(
+ "\xc3\xa9cole",
+ Sanitizer::decodeCharReferences( '&eacute;cole' ) );
+ }
+
+ function testDecodeNumbered() {
+ $this->assertEquals(
+ "\xc4\x88io bonas dans l'\xc3\xa9cole!",
+ Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&#233;cole!" ) );
+ }
+
+ function testDecodeMixed() {
+ $this->assertEquals(
+ "\xc4\x88io bonas dans l'\xc3\xa9cole!",
+ Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&eacute;cole!" ) );
+ }
+
+ function testDecodeMixedComplex() {
+ $this->assertEquals(
+ "\xc4\x88io bonas dans l'\xc3\xa9cole! (mais pas &#x108;io dans l'&eacute;cole)",
+ Sanitizer::decodeCharReferences( "&#x108;io bonas dans l'&eacute;cole! (mais pas &amp;#x108;io dans l'&#38;eacute;cole)" ) );
+ }
+
+ function testDecodeInvalidAmp() {
+ $this->assertEquals(
+ "a & b",
+ Sanitizer::decodeCharReferences( "a & b" ) );
+ }
+
+ function testDecodeInvalidNamed() {
+ $this->assertEquals(
+ "&foo;",
+ Sanitizer::decodeCharReferences( "&foo;" ) );
+ }
+
+ function testDecodeInvalidNumbered() {
+ $this->assertEquals(
+ UTF8_REPLACEMENT,
+ Sanitizer::decodeCharReferences( "&#88888888888888;" ) );
+ }
+
+ /* TODO: many more! */
+}
+
+?> \ No newline at end of file