65 lines
No EOL
1.6 KiB
PHP
65 lines
No EOL
1.6 KiB
PHP
<?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( 'école' ) );
|
|
}
|
|
|
|
function testDecodeNumbered() {
|
|
$this->assertEquals(
|
|
"\xc4\x88io bonas dans l'\xc3\xa9cole!",
|
|
Sanitizer::decodeCharReferences( "Ĉio bonas dans l'école!" ) );
|
|
}
|
|
|
|
function testDecodeMixed() {
|
|
$this->assertEquals(
|
|
"\xc4\x88io bonas dans l'\xc3\xa9cole!",
|
|
Sanitizer::decodeCharReferences( "Ĉio bonas dans l'école!" ) );
|
|
}
|
|
|
|
function testDecodeMixedComplex() {
|
|
$this->assertEquals(
|
|
"\xc4\x88io bonas dans l'\xc3\xa9cole! (mais pas Ĉio dans l'école)",
|
|
Sanitizer::decodeCharReferences( "Ĉio bonas dans l'école! (mais pas &#x108;io dans l'&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( "�" ) );
|
|
}
|
|
|
|
/* TODO: many more! */
|
|
}
|
|
|
|
?>
|