diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2008-12-15 18:02:47 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2008-12-15 18:02:47 +0100 |
commit | 396b28f3d881f5debd888ba9bb9b47c2d478a76f (patch) | |
tree | 10d6e1a721ee4ef69def34a57f02d7eb3fc9e31e /tests | |
parent | 0be4d3ccf6c4fe98a72704f9463ecdea2ee5e615 (diff) |
update to Mediawiki 1.13.3; some cleanups
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ImageTest.php | 66 | ||||
-rw-r--r-- | tests/LocalTestSettings.sample | 29 | ||||
-rw-r--r-- | tests/RunTests.php | 100 | ||||
-rw-r--r-- | tests/SanitizerTest.php | 65 |
4 files changed, 0 insertions, 260 deletions
diff --git a/tests/ImageTest.php b/tests/ImageTest.php deleted file mode 100644 index b06d4cbf..00000000 --- a/tests/ImageTest.php +++ /dev/null @@ -1,66 +0,0 @@ -<?php - -require_once( 'PHPUnit.php' ); -require_once( '../includes/Defines.php' ); -require_once( '../includes/Profiling.php' ); -require_once( '../includes/GlobalFunctions.php' ); -require_once( '../includes/Image.php' ); - -class ImageTest extends PHPUnit_TestCase { - function ImageTest( $name ) { - $this->PHPUnit_TestCase( $name ); - } - - function setUp() { - } - - function tearDown() { - } - - function testFitBoxWidth() { - $vals = array( - array( - 'width' => 50, - 'height' => 50, - 'tests' => array( - 50 => 50, - 17 => 17, - 18 => 18 ) ), - array( - 'width' => 366, - 'height' => 300, - 'tests' => array( - 50 => 61, - 17 => 21, - 18 => 22 ) ), - array( - 'width' => 300, - 'height' => 366, - 'tests' => array( - 50 => 41, - 17 => 14, - 18 => 15 ) ), - array( - 'width' => 100, - 'height' => 400, - 'tests' => array( - 50 => 12, - 17 => 4, - 18 => 4 ) ) ); - foreach( $vals as $row ) { - extract( $row ); - foreach( $tests as $max => $expected ) { - $y = round( $expected * $height / $width ); - $result = wfFitBoxWidth( $width, $height, $max ); - $y2 = round( $result * $height / $width ); - $this->assertEquals( $expected, - $result, - "($width, $height, $max) wanted: {$expected}x$y, got: {$result}x$y2" ); - } - } - } - - /* TODO: many more! */ -} - -?>
\ No newline at end of file diff --git a/tests/LocalTestSettings.sample b/tests/LocalTestSettings.sample deleted file mode 100644 index 7ada2fda..00000000 --- a/tests/LocalTestSettings.sample +++ /dev/null @@ -1,29 +0,0 @@ -<?php -# This contains basic configuration values that are needed -# for RunTests.php. - -# Full path to the mediawiki source code you want to test -$IP = '/var/www/mediawiki-cvs'; - -# Now we add that path to the default include_path -ini_set('include_path',ini_get('include_path').':'.$IP); - -# Some options needed for database testing -$testOptions = array( - 'mysql3' => array( - 'server' => null, - 'user' => null, - 'password' => null, - 'database' => null ), - 'mysql4' => array( - 'server' => null, - 'user' => null, - 'password' => null, - 'database' => null ), - 'postgres' => array( - 'server' => null, - 'user' => null, - 'password' => null, - 'database' => null ), - ); -?> diff --git a/tests/RunTests.php b/tests/RunTests.php deleted file mode 100644 index 2b539a47..00000000 --- a/tests/RunTests.php +++ /dev/null @@ -1,100 +0,0 @@ -<?php - -if( php_sapi_name() != 'cli' ) { - echo 'Must be run from the command line.'; - die( -1 ); -} - -error_reporting( E_ALL ); -define( "MEDIAWIKI", true ); - -set_include_path( get_include_path() . PATH_SEPARATOR . 'PHPUnit' ); -set_include_path( get_include_path() . PATH_SEPARATOR . '..' ); -require_once( 'PHPUnit.php' ); - -$testOptions = array( - 'mysql4' => array( - 'server' => null, - 'user' => null, - 'password' => null, - 'database' => null ), - 'postgres' => array( - 'server' => null, - 'user' => null, - 'password' => null, - 'database' => null ), - ); - -if( file_exists( 'LocalTestSettings.php' ) ) { - include( './LocalTestSettings.php' ); -} - -$tests = array( - 'GlobalTest', - 'DatabaseTest', - 'SearchMySQL4Test', - 'ArticleTest', - 'SanitizerTest', - 'ImageTest' - ); - -if( isset( $_SERVER['argv'][1] ) ) { - // to override... - $tests = array( $_SERVER['argv'][1] ); -} - -foreach( $tests as $test ) { - require_once( $test . '.php' ); - $suite = new PHPUnit_TestSuite( $test ); - $result = PHPUnit::run( $suite ); - echo $result->toString(); -} - -/** - * @param string $serverType - * @param array $tables - */ -function &buildTestDatabase( $serverType, $tables ) { - global $testOptions, $wgDBprefix; - $wgDBprefix = 'parsertest'; - $db = new Database( - $testOptions[$serverType]['server'], - $testOptions[$serverType]['user'], - $testOptions[$serverType]['password'], - $testOptions[$serverType]['database'] ); - if( $db->isOpen() ) { - if (!(strcmp($db->getServerVersion(), '4.1') < 0 and stristr($db->getSoftwareLink(), 'MySQL'))) { - # Database that supports CREATE TABLE ... LIKE - foreach ($tables as $tbl) { - $newTableName = $db->tableName( $tbl ); - #$tableName = $this->oldTableNames[$tbl]; - $tableName = $tbl; - $db->query("CREATE TEMPORARY TABLE $newTableName (LIKE $tableName INCLUDING DEFAULTS)"); - } - } else { - # Hack for MySQL versions < 4.1, which don't support - # "CREATE TABLE ... LIKE". Note that - # "CREATE TEMPORARY TABLE ... SELECT * FROM ... LIMIT 0" - # would not create the indexes we need.... - foreach ($tables as $tbl) { - $res = $db->query("SHOW CREATE TABLE $tbl"); - $row = $db->fetchRow($res); - $create = $row[1]; - $create_tmp = preg_replace('/CREATE TABLE `(.*?)`/', 'CREATE TEMPORARY TABLE `' - . $wgDBprefix . '\\1`', $create); - if ($create === $create_tmp) { - # Couldn't do replacement - wfDie( "could not create temporary table $tbl" ); - } - $db->query($create_tmp); - } - - } - return $db; - } else { - // Something amiss - return null; - } -} - -?> diff --git a/tests/SanitizerTest.php b/tests/SanitizerTest.php deleted file mode 100644 index 5babf0ae..00000000 --- a/tests/SanitizerTest.php +++ /dev/null @@ -1,65 +0,0 @@ -<?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! */ -} - -?>
\ No newline at end of file |