diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2007-05-16 20:58:53 +0000 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2007-05-16 20:58:53 +0000 |
commit | cecb985bee3bdd252e1b8dc0bd500b37cd52be01 (patch) | |
tree | 17266aa237742640aabee7856f0202317a45d540 /t/inc | |
parent | 0bac06c301f2a83edb0236e4c2434da16848d549 (diff) |
Aktualisierung auf MediaWiki 1.10.0
Plugins angepasst und verbessert
kleine Korrekturen am Design
Diffstat (limited to 't/inc')
-rw-r--r-- | t/inc/IP.t | 60 | ||||
-rw-r--r-- | t/inc/Licenses.t | 29 | ||||
-rw-r--r-- | t/inc/Sanitizer.t | 62 | ||||
-rw-r--r-- | t/inc/Title.t | 33 | ||||
-rw-r--r-- | t/inc/Xml.t | 56 |
5 files changed, 240 insertions, 0 deletions
diff --git a/t/inc/IP.t b/t/inc/IP.t new file mode 100644 index 00000000..eb4978b9 --- /dev/null +++ b/t/inc/IP.t @@ -0,0 +1,60 @@ +#!/usr/bin/env php +<?php + +require 'Test.php'; + +plan( 1120 ); + +require_ok( 'includes/IP.php' ); + +# some of this test data was taken from Data::Validate::IP + +# +# isValid() +# + +foreach ( range( 0, 255 ) as $i ) { + $a = sprintf( "%03d", $i ); + $b = sprintf( "%02d", $i ); + $c = sprintf( "%01d", $i ); + foreach ( array_unique( array( $a, $b, $c ) ) as $f ) { + $ip = "$f.$f.$f.$f"; + ok( IP::isValid( $ip ), "$ip is a valid IPv4 address" ); + } +} + +# A bit excessive perhaps? meh.. +foreach ( range( 256, 999 ) as $i ) { + $a = sprintf( "%03d", $i ); + $b = sprintf( "%02d", $i ); + $c = sprintf( "%01d", $i ); + foreach ( array_unique( array( $a, $b, $c ) ) as $f ) { + $ip = "$f.$f.$f.$f"; + ok( ! IP::isValid( $ip ), "$ip is not a valid IPv4 address" ); + } +} + +$invalid = array( + 'www.xn--var-xla.net', + '216.17.184.G', + '216.17.184.1.', + '216.17.184', + '216.17.184.', + '256.17.184.1' +); + +foreach ( $invalid as $i ) { + ok( ! IP::isValid( $i ), "$i is an invalid IPv4 address" ); +} + +# +# isPublic() +# + +$private = array( '10.0.0.1', '172.16.0.1', '192.168.0.1' ); + +foreach ( $private as $p ) { + ok( ! IP::isPublic( $p ), "$p is not a public IP address" ); +} + +?> diff --git a/t/inc/Licenses.t b/t/inc/Licenses.t new file mode 100644 index 00000000..86202bd6 --- /dev/null +++ b/t/inc/Licenses.t @@ -0,0 +1,29 @@ +#!/usr/bin/env php +<?php +require 'Test.php'; + +plan(3); + +error_reporting( E_ALL ); + +define( 'MEDIAWIKI', 1 ); // Hack + +require_ok( 'languages/Language.php' ); +require_ok( 'includes/GlobalFunctions.php' ); +require_ok( 'includes/Licenses.php' ); + +$str = " +* Free licenses: +** GFLD|Debian disagrees +"; + +#$lc = new Licenses ( $str ); + +#isa_ok( $lc, 'Licenses' ); + +#echo $lc->html; + + + + +?>
\ No newline at end of file diff --git a/t/inc/Sanitizer.t b/t/inc/Sanitizer.t new file mode 100644 index 00000000..e3b11b6f --- /dev/null +++ b/t/inc/Sanitizer.t @@ -0,0 +1,62 @@ +#!/usr/bin/env php +<?php + +require 'Test.php'; + +plan( 13 ); + +define( 'MEDIAWIKI', 1 ); +require_ok( 'includes/Defines.php' ); +require_ok( 'includes/GlobalFunctions.php' ); +require_ok( 'includes/Sanitizer.php' ); +require_ok( 'includes/normal/UtfNormal.php' ); +require_ok( 'includes/ProfilerStub.php' ); # For removeHTMLtags + + +# +# decodeCharReferences +# + +cmp_ok( + Sanitizer::decodeCharReferences( 'école' ), + '==', + "\xc3\xa9cole", + 'decode named entities' +); + +cmp_ok( + Sanitizer::decodeCharReferences( "Ĉio bonas dans l'école!" ), + '==', + "\xc4\x88io bonas dans l'\xc3\xa9cole!", + 'decode numeric entities' +); + +cmp_ok( + Sanitizer::decodeCharReferences( "Ĉio bonas dans l'école!" ), + '==', + "\xc4\x88io bonas dans l'\xc3\xa9cole!", + 'decode mixed numeric/named entities' +); + +cmp_ok( + Sanitizer::decodeCharReferences( + "Ĉio bonas dans l'école! (mais pas &#x108;io dans l'&eacute;cole)" + ), + '==', + "\xc4\x88io bonas dans l'\xc3\xa9cole! (mais pas Ĉio dans l'école)", + 'decode mixed complex entities' +); + +cmp_ok( Sanitizer::decodeCharReferences( 'a & b' ), '==', 'a & b', 'Invalid ampersand' ); + +cmp_ok( Sanitizer::decodeCharReferences( '&foo;' ), '==', '&foo;', 'Invalid named entity' ); + +cmp_ok( Sanitizer::decodeCharReferences( "�" ), '==', UTF8_REPLACEMENT, 'Invalid numbered entity' ); + +$wgUseTidy = false; +cmp_ok( + Sanitizer::removeHTMLtags( '<div>Hello world</div />' ), + '==', + '<div>Hello world</div>', + 'Self-closing closing div' +); diff --git a/t/inc/Title.t b/t/inc/Title.t new file mode 100644 index 00000000..51157197 --- /dev/null +++ b/t/inc/Title.t @@ -0,0 +1,33 @@ +#!/usr/bin/env php +<?php + +require 'Test.php'; + +plan( 2 + 255 ); + +require_ok( 'includes/Defines.php' ); + +# require_ok() doesn't work for these, find out why +define( 'MEDIAWIKI', 1 ); +require 'LocalSettings.php'; +require 'includes/DefaultSettings.php'; + +require_ok( 'includes/Title.php' ); + +# +# legalChars() +# + +$titlechars = Title::legalChars(); + +foreach ( range( 1, 255 ) as $num ) { + $chr = chr( $num ); + if ( strpos( "#[]{}<>|", $chr ) !== false || preg_match( "/[\\x00-\\x1f\\x7f]/", $chr ) ) { + unlike( $chr, "/[$titlechars]/", "chr($num) = $chr is not a valid titlechar" ); + } else { + like( $chr, "/[$titlechars]/", "chr($num) = $chr is a valid titlechar" ); + } +} + + +?> diff --git a/t/inc/Xml.t b/t/inc/Xml.t new file mode 100644 index 00000000..bf95cce2 --- /dev/null +++ b/t/inc/Xml.t @@ -0,0 +1,56 @@ +#!/usr/bin/env php +<?php + +require 'Test.php'; + +plan( 8 ); + +require_ok( 'includes/Sanitizer.php' ); +require_ok( 'includes/Xml.php' ); + +# +# element +# + +cmp_ok( + Xml::element( 'element', null, null ), + '==', + '<element>', + 'Opening element with no attributes' +); + +cmp_ok( + Xml::element( 'element', null, '' ), + '==', + '<element />', + 'Terminated empty element' +); + +cmp_ok( + Xml::element( 'element', null, 'hello <there> you & you' ), + '==', + '<element>hello <there> you & you</element>', + 'Element with no attributes and content that needs escaping' +); + +cmp_ok( + Xml::element( 'element', array( 'key' => 'value', '<>' => '<>' ), null ), + '==', + '<element key="value" <>="<>">', + 'Element attributes, keys are not escaped' +); + +# +# open/close element +# + +cmp_ok( + Xml::openElement( 'element', array( 'k' => 'v' ) ), + '==', + '<element k="v">', + 'openElement() shortcut' +); + +cmp_ok( Xml::closeElement( 'element' ), '==', '</element>', 'closeElement() shortcut' ); + +?>
\ No newline at end of file |