From 396b28f3d881f5debd888ba9bb9b47c2d478a76f Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Mon, 15 Dec 2008 18:02:47 +0100 Subject: update to Mediawiki 1.13.3; some cleanups --- tests/ImageTest.php | 66 --------------------------- tests/LocalTestSettings.sample | 29 ------------ tests/RunTests.php | 100 ----------------------------------------- tests/SanitizerTest.php | 65 --------------------------- 4 files changed, 260 deletions(-) delete mode 100644 tests/ImageTest.php delete mode 100644 tests/LocalTestSettings.sample delete mode 100644 tests/RunTests.php delete mode 100644 tests/SanitizerTest.php (limited to 'tests') 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 @@ -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 @@ - 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 @@ - 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 @@ -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 -- cgit v1.2.2