diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2010-07-28 11:52:48 +0200 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2010-07-28 11:52:48 +0200 |
commit | 222b01f5169f1c7e69762e0e8904c24f78f71882 (patch) | |
tree | 8e932e12546bb991357ec48eb1638d1770be7a35 /tests | |
parent | 00ab76a6b686e98a914afc1975812d2b1aaa7016 (diff) |
update to MediaWiki 1.16.0
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.htaccess | 1 | ||||
-rw-r--r-- | tests/.svnignore | 6 | ||||
-rw-r--r-- | tests/ArticleTest.php | 110 | ||||
-rw-r--r-- | tests/DatabaseTest.php | 80 | ||||
-rw-r--r-- | tests/GlobalTest.php | 212 | ||||
-rw-r--r-- | tests/ImageFunctionsTest.php | 48 | ||||
-rw-r--r-- | tests/LocalFileTest.php | 90 | ||||
-rw-r--r-- | tests/Makefile | 19 | ||||
-rw-r--r-- | tests/MediaWiki_TestCase.php | 51 | ||||
-rw-r--r-- | tests/README | 9 | ||||
-rw-r--r-- | tests/SearchEngineTest.php | 136 | ||||
-rw-r--r-- | tests/SearchMySQL4Test.php | 31 | ||||
-rw-r--r-- | tests/run-test.php | 7 | ||||
-rw-r--r-- | tests/test-prefetch-current.xml | 75 | ||||
-rw-r--r-- | tests/test-prefetch-previous.xml | 57 | ||||
-rw-r--r-- | tests/test-prefetch-stub.xml | 75 |
16 files changed, 0 insertions, 1007 deletions
diff --git a/tests/.htaccess b/tests/.htaccess deleted file mode 100644 index 3a428827..00000000 --- a/tests/.htaccess +++ /dev/null @@ -1 +0,0 @@ -Deny from all diff --git a/tests/.svnignore b/tests/.svnignore deleted file mode 100644 index 20cb61e9..00000000 --- a/tests/.svnignore +++ /dev/null @@ -1,6 +0,0 @@ -LocalTestSettings.php -*~ -bin -.classpath -.project -project.index diff --git a/tests/ArticleTest.php b/tests/ArticleTest.php deleted file mode 100644 index a65e1ee3..00000000 --- a/tests/ArticleTest.php +++ /dev/null @@ -1,110 +0,0 @@ -<?php - -class ArticleTest extends PHPUnit_Framework_TestCase { - var $saveGlobals = array(); - - function setUp() { - $globalSet = array( - 'wgLegacyEncoding' => false, - 'wgCompressRevisions' => false, - 'wgInputEncoding' => 'utf-8', - 'wgOutputEncoding' => 'utf-8' ); - foreach( $globalSet as $var => $data ) { - $this->saveGlobals[$var] = $GLOBALS[$var]; - $GLOBALS[$var] = $data; - } - } - - function tearDown() { - foreach( $this->saveGlobals as $var => $data ) { - $GLOBALS[$var] = $data; - } - } - - function testGetRevisionText() { - $row = new stdClass; - $row->old_flags = ''; - $row->old_text = 'This is a bunch of revision text.'; - $this->assertEquals( - 'This is a bunch of revision text.', - Revision::getRevisionText( $row ) ); - } - - function testGetRevisionTextGzip() { - $row = new stdClass; - $row->old_flags = 'gzip'; - $row->old_text = gzdeflate( 'This is a bunch of revision text.' ); - $this->assertEquals( - 'This is a bunch of revision text.', - Revision::getRevisionText( $row ) ); - } - - function testGetRevisionTextUtf8Native() { - $row = new stdClass; - $row->old_flags = 'utf-8'; - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; - $this->assertEquals( - "Wiki est l'\xc3\xa9cole superieur !", - Revision::getRevisionText( $row ) ); - } - - function testGetRevisionTextUtf8Legacy() { - $row = new stdClass; - $row->old_flags = ''; - $row->old_text = "Wiki est l'\xe9cole superieur !"; - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; - $this->assertEquals( - "Wiki est l'\xc3\xa9cole superieur !", - Revision::getRevisionText( $row ) ); - } - - function testGetRevisionTextUtf8NativeGzip() { - $row = new stdClass; - $row->old_flags = 'gzip,utf-8'; - $row->old_text = gzdeflate( "Wiki est l'\xc3\xa9cole superieur !" ); - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; - $this->assertEquals( - "Wiki est l'\xc3\xa9cole superieur !", - Revision::getRevisionText( $row ) ); - } - - function testGetRevisionTextUtf8LegacyGzip() { - $row = new stdClass; - $row->old_flags = 'gzip'; - $row->old_text = gzdeflate( "Wiki est l'\xe9cole superieur !" ); - $GLOBALS['wgLegacyEncoding'] = 'iso-8859-1'; - $this->assertEquals( - "Wiki est l'\xc3\xa9cole superieur !", - Revision::getRevisionText( $row ) ); - } - - function testCompressRevisionTextUtf8() { - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; - $row->old_flags = Revision::compressRevisionText( $row->old_text ); - $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ), - "Flags should contain 'utf-8'" ); - $this->assertFalse( false !== strpos( $row->old_flags, 'gzip' ), - "Flags should not contain 'gzip'" ); - $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", - $row->old_text, "Direct check" ); - $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", - Revision::getRevisionText( $row ), "getRevisionText" ); - } - - function testCompressRevisionTextUtf8Gzip() { - $GLOBALS['wgCompressRevisions'] = true; - $row->old_text = "Wiki est l'\xc3\xa9cole superieur !"; - $row->old_flags = Revision::compressRevisionText( $row->old_text ); - $this->assertTrue( false !== strpos( $row->old_flags, 'utf-8' ), - "Flags should contain 'utf-8'" ); - $this->assertTrue( false !== strpos( $row->old_flags, 'gzip' ), - "Flags should contain 'gzip'" ); - $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", - gzinflate( $row->old_text ), "Direct check" ); - $this->assertEquals( "Wiki est l'\xc3\xa9cole superieur !", - Revision::getRevisionText( $row ), "getRevisionText" ); - } -} - - diff --git a/tests/DatabaseTest.php b/tests/DatabaseTest.php deleted file mode 100644 index db46ad60..00000000 --- a/tests/DatabaseTest.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -class DatabaseTest extends PHPUnit_Framework_TestCase { - var $db; - - function setUp() { - $this->db = wfGetDB( DB_SLAVE ); - } - - function testAddQuotesNull() { - $this->assertEquals( - 'NULL', - $this->db->addQuotes( NULL ) ); - } - - function testAddQuotesInt() { - # returning just "1234" should be ok too, though... - # maybe - $this->assertEquals( - "'1234'", - $this->db->addQuotes( 1234 ) ); - } - - function testAddQuotesFloat() { - # returning just "1234.5678" would be ok too, though - $this->assertEquals( - "'1234.5678'", - $this->db->addQuotes( 1234.5678 ) ); - } - - function testAddQuotesString() { - $this->assertEquals( - "'string'", - $this->db->addQuotes( 'string' ) ); - } - - function testAddQuotesStringQuote() { - $this->assertEquals( - "'string\'s cause trouble'", - $this->db->addQuotes( "string's cause trouble" ) ); - } - - function testFillPreparedEmpty() { - $sql = $this->db->fillPrepared( - 'SELECT * FROM interwiki', array() ); - $this->assertEquals( - "SELECT * FROM interwiki", - $sql); - } - - function testFillPreparedQuestion() { - $sql = $this->db->fillPrepared( - 'SELECT * FROM cur WHERE cur_namespace=? AND cur_title=?', - array( 4, "Snicker's_paradox" ) ); - $this->assertEquals( - "SELECT * FROM cur WHERE cur_namespace='4' AND cur_title='Snicker\'s_paradox'", - $sql); - } - - function testFillPreparedBang() { - $sql = $this->db->fillPrepared( - 'SELECT user_id FROM ! WHERE user_name=?', - array( '"user"', "Slash's Dot" ) ); - $this->assertEquals( - "SELECT user_id FROM \"user\" WHERE user_name='Slash\'s Dot'", - $sql); - } - - function testFillPreparedRaw() { - $sql = $this->db->fillPrepared( - "SELECT * FROM cur WHERE cur_title='This_\\&_that,_WTF\\?\\!'", - array( '"user"', "Slash's Dot" ) ); - $this->assertEquals( - "SELECT * FROM cur WHERE cur_title='This_&_that,_WTF?!'", - $sql); - } - -} - - diff --git a/tests/GlobalTest.php b/tests/GlobalTest.php deleted file mode 100644 index ec694241..00000000 --- a/tests/GlobalTest.php +++ /dev/null @@ -1,212 +0,0 @@ -<?php - -class GlobalTest extends PHPUnit_Framework_TestCase { - function setUp() { - global $wgReadOnlyFile; - $this->originals['wgReadOnlyFile'] = $wgReadOnlyFile; - $wgReadOnlyFile = tempnam(wfTempDir(), "mwtest_readonly"); - unlink( $wgReadOnlyFile ); - } - - function tearDown() { - global $wgReadOnlyFile; - if( file_exists( $wgReadOnlyFile ) ) { - unlink( $wgReadOnlyFile ); - } - $wgReadOnlyFile = $this->originals['wgReadOnlyFile']; - } - - function testRandom() { - # This could hypothetically fail, but it shouldn't ;) - $this->assertFalse( - wfRandom() == wfRandom() ); - } - - function testUrlencode() { - $this->assertEquals( - "%E7%89%B9%E5%88%A5:Contributions/Foobar", - wfUrlencode( "\xE7\x89\xB9\xE5\x88\xA5:Contributions/Foobar" ) ); - } - - function testReadOnlyEmpty() { - global $wgReadOnly; - $wgReadOnly = null; - - $this->assertFalse( wfReadOnly() ); - $this->assertFalse( wfReadOnly() ); - } - - function testReadOnlySet() { - global $wgReadOnly, $wgReadOnlyFile; - - $f = fopen( $wgReadOnlyFile, "wt" ); - fwrite( $f, 'Message' ); - fclose( $f ); - $wgReadOnly = null; - - $this->assertTrue( wfReadOnly() ); - $this->assertTrue( wfReadOnly() ); - - unlink( $wgReadOnlyFile ); - $wgReadOnly = null; - - $this->assertFalse( wfReadOnly() ); - $this->assertFalse( wfReadOnly() ); - } - - function testQuotedPrintable() { - $this->assertEquals( - "=?UTF-8?Q?=C4=88u=20legebla=3F?=", - wfQuotedPrintable( "\xc4\x88u legebla?", "UTF-8" ) ); - } - - function testTime() { - $start = wfTime(); - $this->assertType( 'float', $start ); - $end = wfTime(); - $this->assertTrue( $end > $start, "Time is running backwards!" ); - } - - function testArrayToCGI() { - $this->assertEquals( - "baz=AT%26T&foo=bar", - wfArrayToCGI( - array( 'baz' => 'AT&T', 'ignore' => '' ), - array( 'foo' => 'bar', 'baz' => 'overridden value' ) ) ); - } - - function testMimeTypeMatch() { - $this->assertEquals( - 'text/html', - mimeTypeMatch( 'text/html', - array( 'application/xhtml+xml' => 1.0, - 'text/html' => 0.7, - 'text/plain' => 0.3 ) ) ); - $this->assertEquals( - 'text/*', - mimeTypeMatch( 'text/html', - array( 'image/*' => 1.0, - 'text/*' => 0.5 ) ) ); - $this->assertEquals( - '*/*', - mimeTypeMatch( 'text/html', - array( '*/*' => 1.0 ) ) ); - $this->assertNull( - mimeTypeMatch( 'text/html', - array( 'image/png' => 1.0, - 'image/svg+xml' => 0.5 ) ) ); - } - - function testNegotiateType() { - $this->assertEquals( - 'text/html', - wfNegotiateType( - array( 'application/xhtml+xml' => 1.0, - 'text/html' => 0.7, - 'text/plain' => 0.5, - 'text/*' => 0.2 ), - array( 'text/html' => 1.0 ) ) ); - $this->assertEquals( - 'application/xhtml+xml', - wfNegotiateType( - array( 'application/xhtml+xml' => 1.0, - 'text/html' => 0.7, - 'text/plain' => 0.5, - 'text/*' => 0.2 ), - array( 'application/xhtml+xml' => 1.0, - 'text/html' => 0.5 ) ) ); - $this->assertEquals( - 'text/html', - wfNegotiateType( - array( 'text/html' => 1.0, - 'text/plain' => 0.5, - 'text/*' => 0.5, - 'application/xhtml+xml' => 0.2 ), - array( 'application/xhtml+xml' => 1.0, - 'text/html' => 0.5 ) ) ); - $this->assertEquals( - 'text/html', - wfNegotiateType( - array( 'text/*' => 1.0, - 'image/*' => 0.7, - '*/*' => 0.3 ), - array( 'application/xhtml+xml' => 1.0, - 'text/html' => 0.5 ) ) ); - $this->assertNull( - wfNegotiateType( - array( 'text/*' => 1.0 ), - array( 'application/xhtml+xml' => 1.0 ) ) ); - } - - function testTimestamp() { - $t = gmmktime( 12, 34, 56, 1, 15, 2001 ); - $this->assertEquals( - '20010115123456', - wfTimestamp( TS_MW, $t ), - 'TS_UNIX to TS_MW' ); - $this->assertEquals( - 979562096, - wfTimestamp( TS_UNIX, $t ), - 'TS_UNIX to TS_UNIX' ); - $this->assertEquals( - '2001-01-15 12:34:56', - wfTimestamp( TS_DB, $t ), - 'TS_UNIX to TS_DB' ); - - $this->assertEquals( - '20010115123456', - wfTimestamp( TS_MW, '20010115123456' ), - 'TS_MW to TS_MW' ); - $this->assertEquals( - 979562096, - wfTimestamp( TS_UNIX, '20010115123456' ), - 'TS_MW to TS_UNIX' ); - $this->assertEquals( - '2001-01-15 12:34:56', - wfTimestamp( TS_DB, '20010115123456' ), - 'TS_MW to TS_DB' ); - - $this->assertEquals( - '20010115123456', - wfTimestamp( TS_MW, '2001-01-15 12:34:56' ), - 'TS_DB to TS_MW' ); - $this->assertEquals( - 979562096, - wfTimestamp( TS_UNIX, '2001-01-15 12:34:56' ), - 'TS_DB to TS_UNIX' ); - $this->assertEquals( - '2001-01-15 12:34:56', - wfTimestamp( TS_DB, '2001-01-15 12:34:56' ), - 'TS_DB to TS_DB' ); - } - - function testBasename() { - $sets = array( - '' => '', - '/' => '', - '\\' => '', - '//' => '', - '\\\\' => '', - 'a' => 'a', - 'aaaa' => 'aaaa', - '/a' => 'a', - '\\a' => 'a', - '/aaaa' => 'aaaa', - '\\aaaa' => 'aaaa', - '/aaaa/' => 'aaaa', - '\\aaaa\\' => 'aaaa', - '\\aaaa\\' => 'aaaa', - '/mnt/upload3/wikipedia/en/thumb/8/8b/Zork_Grand_Inquisitor_box_cover.jpg/93px-Zork_Grand_Inquisitor_box_cover.jpg' => '93px-Zork_Grand_Inquisitor_box_cover.jpg', - 'C:\\Progra~1\\Wikime~1\\Wikipe~1\\VIEWER.EXE' => 'VIEWER.EXE', - 'Östergötland_coat_of_arms.png' => 'Östergötland_coat_of_arms.png', - ); - foreach( $sets as $from => $to ) { - $this->assertEquals( $to, wfBaseName( $from ), - "wfBaseName('$from') => '$to'"); - } - } - - /* TODO: many more! */ -} - - diff --git a/tests/ImageFunctionsTest.php b/tests/ImageFunctionsTest.php deleted file mode 100644 index 9794a2a2..00000000 --- a/tests/ImageFunctionsTest.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -class ImageFunctionsTest extends PHPUnit_Framework_TestCase { - 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" ); - } - } - } -} - - diff --git a/tests/LocalFileTest.php b/tests/LocalFileTest.php deleted file mode 100644 index 335b8bbe..00000000 --- a/tests/LocalFileTest.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php - -/** - * These tests should work regardless of $wgCapitalLinks - */ - -class LocalFileTest extends PHPUnit_Framework_TestCase { - function setUp() { - $info = array( - 'name' => 'test', - 'directory' => '/testdir', - 'url' => '/testurl', - 'hashLevels' => 2, - 'transformVia404' => false, - ); - $this->repo_hl0 = new LocalRepo( array( 'hashLevels' => 0 ) + $info ); - $this->repo_hl2 = new LocalRepo( array( 'hashLevels' => 2 ) + $info ); - $this->repo_lc = new LocalRepo( array( 'initialCapital' => false ) + $info ); - $this->file_hl0 = $this->repo_hl0->newFile( 'test!' ); - $this->file_hl2 = $this->repo_hl2->newFile( 'test!' ); - $this->file_lc = $this->repo_lc->newFile( 'test!' ); - } - - function testGetHashPath() { - $this->assertEquals( '', $this->file_hl0->getHashPath() ); - $this->assertEquals( 'a/a2/', $this->file_hl2->getHashPath() ); - $this->assertEquals( 'c/c4/', $this->file_lc->getHashPath() ); - } - - function testGetRel() { - $this->assertEquals( 'Test!', $this->file_hl0->getRel() ); - $this->assertEquals( 'a/a2/Test!', $this->file_hl2->getRel() ); - $this->assertEquals( 'c/c4/test!', $this->file_lc->getRel() ); - } - - function testGetUrlRel() { - $this->assertEquals( 'Test%21', $this->file_hl0->getUrlRel() ); - $this->assertEquals( 'a/a2/Test%21', $this->file_hl2->getUrlRel() ); - $this->assertEquals( 'c/c4/test%21', $this->file_lc->getUrlRel() ); - } - - function testGetArchivePath() { - $this->assertEquals( '/testdir/archive', $this->file_hl0->getArchivePath() ); - $this->assertEquals( '/testdir/archive/a/a2', $this->file_hl2->getArchivePath() ); - $this->assertEquals( '/testdir/archive/!', $this->file_hl0->getArchivePath( '!' ) ); - $this->assertEquals( '/testdir/archive/a/a2/!', $this->file_hl2->getArchivePath( '!' ) ); - } - - function testGetThumbPath() { - $this->assertEquals( '/testdir/thumb/Test!', $this->file_hl0->getThumbPath() ); - $this->assertEquals( '/testdir/thumb/a/a2/Test!', $this->file_hl2->getThumbPath() ); - $this->assertEquals( '/testdir/thumb/Test!/x', $this->file_hl0->getThumbPath( 'x' ) ); - $this->assertEquals( '/testdir/thumb/a/a2/Test!/x', $this->file_hl2->getThumbPath( 'x' ) ); - } - - function testGetArchiveUrl() { - $this->assertEquals( '/testurl/archive', $this->file_hl0->getArchiveUrl() ); - $this->assertEquals( '/testurl/archive/a/a2', $this->file_hl2->getArchiveUrl() ); - $this->assertEquals( '/testurl/archive/%21', $this->file_hl0->getArchiveUrl( '!' ) ); - $this->assertEquals( '/testurl/archive/a/a2/%21', $this->file_hl2->getArchiveUrl( '!' ) ); - } - - function testGetThumbUrl() { - $this->assertEquals( '/testurl/thumb/Test%21', $this->file_hl0->getThumbUrl() ); - $this->assertEquals( '/testurl/thumb/a/a2/Test%21', $this->file_hl2->getThumbUrl() ); - $this->assertEquals( '/testurl/thumb/Test%21/x', $this->file_hl0->getThumbUrl( 'x' ) ); - $this->assertEquals( '/testurl/thumb/a/a2/Test%21/x', $this->file_hl2->getThumbUrl( 'x' ) ); - } - - function testGetArchiveVirtualUrl() { - $this->assertEquals( 'mwrepo://test/public/archive', $this->file_hl0->getArchiveVirtualUrl() ); - $this->assertEquals( 'mwrepo://test/public/archive/a/a2', $this->file_hl2->getArchiveVirtualUrl() ); - $this->assertEquals( 'mwrepo://test/public/archive/%21', $this->file_hl0->getArchiveVirtualUrl( '!' ) ); - $this->assertEquals( 'mwrepo://test/public/archive/a/a2/%21', $this->file_hl2->getArchiveVirtualUrl( '!' ) ); - } - - function testGetThumbVirtualUrl() { - $this->assertEquals( 'mwrepo://test/public/thumb/Test%21', $this->file_hl0->getThumbVirtualUrl() ); - $this->assertEquals( 'mwrepo://test/public/thumb/a/a2/Test%21', $this->file_hl2->getThumbVirtualUrl() ); - $this->assertEquals( 'mwrepo://test/public/thumb/Test%21/%21', $this->file_hl0->getThumbVirtualUrl( '!' ) ); - $this->assertEquals( 'mwrepo://test/public/thumb/a/a2/Test%21/%21', $this->file_hl2->getThumbVirtualUrl( '!' ) ); - } - - function testGetUrl() { - $this->assertEquals( '/testurl/Test%21', $this->file_hl0->getUrl() ); - $this->assertEquals( '/testurl/a/a2/Test%21', $this->file_hl2->getUrl() ); - } -} - - diff --git a/tests/Makefile b/tests/Makefile deleted file mode 100644 index 25ccda35..00000000 --- a/tests/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -.PHONY: help test -all test: - php run-test.php ArticleTest.php - php run-test.php GlobalTest.php - php run-test.php DatabaseTest.php - php run-test.php ImageFunctionsTest.php - php run-test.php SearchMySQL4Test.php -install: - cvs -z9 -d:pserver:cvsread:@cvs.php.net:/repository/ co -P pear/PHPUnit - mv pear/PHPUnit . - rm -rf pear -clean: - rm -rf PHPUnit pear -help: - # Options: - # test (default) Run the unit tests - # install Install PHPUnit from CVS - # clean Remove local PHPUnit install - # help You're looking at it! diff --git a/tests/MediaWiki_TestCase.php b/tests/MediaWiki_TestCase.php deleted file mode 100644 index 387fe011..00000000 --- a/tests/MediaWiki_TestCase.php +++ /dev/null @@ -1,51 +0,0 @@ -<?php - -abstract class MediaWiki_TestCase extends PHPUnit_Framework_TestCase { - /** - * @param string $serverType - * @param array $tables - */ - protected function buildTestDatabase( $tables ) { - global $testOptions, $wgDBprefix, $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname; - $wgDBprefix = 'parsertest_'; - $db = new Database( - $wgDBserver, - $wgDBadminuser, - $wgDBadminpassword, - $wgDBname ); - 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)"); - } - } 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/README b/tests/README deleted file mode 100644 index 3bbf9704..00000000 --- a/tests/README +++ /dev/null @@ -1,9 +0,0 @@ -Some quickie unit tests done with the PHPUnit testing framework. To run the -test suite, run 'make test' in this dir or 'php RunTests.php' - -PHPUnit is no longer maintained by PEAR. To get the current version of -PHPUnit, first uninstall any old version of PHPUnit or PHPUnit2 from PEAR, -then install the current version from phpunit.de like this: - -# pear channel-discover pear.phpunit.de -# pear install phpunit/PHPUnit diff --git a/tests/SearchEngineTest.php b/tests/SearchEngineTest.php deleted file mode 100644 index 0ae14bdd..00000000 --- a/tests/SearchEngineTest.php +++ /dev/null @@ -1,136 +0,0 @@ -<?php - -require_once 'MediaWiki_TestCase.php'; - -/** @todo document */ -class SearchEngineTest extends MediaWiki_TestCase { - var $db, $search; - - function insertSearchData() { - $this->db->safeQuery( <<<END - INSERT INTO ! (page_id,page_namespace,page_title,page_latest) - VALUES (1, 0, 'Main_Page', 1), - (2, 1, 'Main_Page', 2), - (3, 0, 'Smithee', 3), - (4, 1, 'Smithee', 4), - (5, 0, 'Unrelated_page', 5), - (6, 0, 'Another_page', 6), - (7, 4, 'Help', 7), - (8, 0, 'Thppt', 8), - (9, 0, 'Alan_Smithee', 9), - (10, 0, 'Pages', 10) -END - , $this->db->tableName( 'page' ) ); - $this->db->safeQuery( <<<END - INSERT INTO ! (rev_id,rev_page) - VALUES (1, 1), - (2, 2), - (3, 3), - (4, 4), - (5, 5), - (6, 6), - (7, 7), - (8, 8), - (9, 9), - (10, 10) -END - , $this->db->tableName( 'revision' ) ); - $this->db->safeQuery( <<<END - INSERT INTO ! (old_id,old_text) - VALUES (1, 'This is a main page'), - (2, 'This is a talk page to the main page, see [[smithee]]'), - (3, 'A smithee is one who smiths. See also [[Alan Smithee]]'), - (4, 'This article sucks.'), - (5, 'Nothing in this page is about the S word.'), - (6, 'This page also is unrelated.'), - (7, 'Help me!'), - (8, 'Blah blah'), - (9, 'yum'), - (10,'are food') -END - , $this->db->tableName( 'text' ) ); - $this->db->safeQuery( <<<END - INSERT INTO ! (si_page,si_title,si_text) - VALUES (1, 'main page', 'this is a main page'), - (2, 'main page', 'this is a talk page to the main page, see smithee'), - (3, 'smithee', 'a smithee is one who smiths see also alan smithee'), - (4, 'smithee', 'this article sucks'), - (5, 'unrelated page', 'nothing in this page is about the s word'), - (6, 'another page', 'this page also is unrelated'), - (7, 'help', 'help me'), - (8, 'thppt', 'blah blah'), - (9, 'alan smithee', 'yum'), - (10, 'pages', 'are food') -END - , $this->db->tableName( 'searchindex' ) ); - } - - function fetchIds( &$results ) { - $matches = array(); - while( $row = $results->next() ) { - $matches[] = $row->getTitle()->getPrefixedText(); - } - $results->free(); - # Search is not guaranteed to return results in a certain order; - # sort them numerically so we will compare simply that we received - # the expected matches. - sort( $matches ); - return $matches; - } - - function testTextSearch() { - $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." ); - if( !is_null( $this->db ) ) { - $this->assertEquals( - array( 'Smithee' ), - $this->fetchIds( $this->search->searchText( 'smithee' ) ), - "Plain search failed" ); - } - } - - function testTextPowerSearch() { - $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." ); - if( !is_null( $this->db ) ) { - $this->search->setNamespaces( array( 0, 1, 4 ) ); - $this->assertEquals( - array( - 'Smithee', - 'Talk:Main Page', - ), - $this->fetchIds( $this->search->searchText( 'smithee' ) ), - "Power search failed" ); - } - } - - function testTitleSearch() { - $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." ); - if( !is_null( $this->db ) ) { - $this->assertEquals( - array( - 'Alan Smithee', - 'Smithee', - ), - $this->fetchIds( $this->search->searchTitle( 'smithee' ) ), - "Title search failed" ); - } - } - - function testTextTitlePowerSearch() { - $this->assertFalse( is_null( $this->db ), "Can't find a database to test with." ); - if( !is_null( $this->db ) ) { - $this->search->setNamespaces( array( 0, 1, 4 ) ); - $this->assertEquals( - array( - 'Alan Smithee', - 'Smithee', - 'Talk:Smithee', - ), - $this->fetchIds( $this->search->searchTitle( 'smithee' ) ), - "Title power search failed" ); - } - } - -} - - - diff --git a/tests/SearchMySQL4Test.php b/tests/SearchMySQL4Test.php deleted file mode 100644 index 0f3a4c2c..00000000 --- a/tests/SearchMySQL4Test.php +++ /dev/null @@ -1,31 +0,0 @@ -<?php -require_once( 'SearchEngineTest.php' ); - -class SearchMySQL4Test extends SearchEngineTest { - var $db; - - function __construct( $name ) { - parent::__construct( $name ); - } - - function setUp() { - $GLOBALS['wgContLang'] = new Language; - $this->db = $this->buildTestDatabase( - array( 'page', 'revision', 'text', 'searchindex' ) ); - if( $this->db ) { - $this->insertSearchData(); - } - $this->search = new SearchMySQL4( $this->db ); - } - - function tearDown() { - if( !is_null( $this->db ) ) { - $this->db->close(); - } - unset( $this->db ); - unset( $this->search ); - } - -} - - diff --git a/tests/run-test.php b/tests/run-test.php deleted file mode 100644 index 37ca8519..00000000 --- a/tests/run-test.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -require_once( dirname(__FILE__) . '/../maintenance/commandLine.inc' ); -ini_set( 'include_path', get_include_path() . PATH_SEPARATOR . /*$_SERVER['PHP_PEAR_INSTALL_DIR']*/ 'C:\php\pear' ); -require( 'PHPUnit/TextUI/Command.php' ); - - diff --git a/tests/test-prefetch-current.xml b/tests/test-prefetch-current.xml deleted file mode 100644 index a4c8bda3..00000000 --- a/tests/test-prefetch-current.xml +++ /dev/null @@ -1,75 +0,0 @@ -<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="en"> -<siteinfo> - <sitename>DemoWiki</sitename> - <base>http://example.com/wiki/Main_Page</base> - <generator>MediaWiki 1.5.0</generator> - <case>first-letter</case> - <namespaces> - <namespace key="-2">Media</namespace> - <namespace key="-1">Special</namespace> - <namespace key="0"></namespace> - <namespace key="1">Talk</namespace> - <namespace key="2">User</namespace> - <namespace key="3">User talk</namespace> - <namespace key="4">DemoWiki</namespace> - <namespace key="5">DemoWIki talk</namespace> - <namespace key="6">Image</namespace> - <namespace key="7">Image talk</namespace> - <namespace key="8">MediaWiki</namespace> - <namespace key="9">MediaWiki talk</namespace> - <namespace key="10">Template</namespace> - <namespace key="11">Template talk</namespace> - <namespace key="12">Help</namespace> - <namespace key="13">Help talk</namespace> - <namespace key="14">Category</namespace> - <namespace key="15">Category talk</namespace> - </namespaces> -</siteinfo> -<page> - <title>First page</title> - <id>1</id> - <revision> - <id>1</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 1, rev 1</comment> - <text>page 1, rev 1</text> - </revision> - <revision> - <id>2</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 1, rev 2</comment> - <text>page 1, rev 2</text> - </revision> - <revision> - <id>4</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 1, rev 4</comment> - <text>page 1, rev 4</text> - </revision> -</page> -<page> - <title>Second page</title> - <id>2</id> - <revision> - <id>3</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 2, rev 3</comment> - <text>page 2, rev 3</text> - </revision> -</page> -<page> - <title>Third page</title> - <id>3</id> - <revision> - <id>5</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 3, rev 5</comment> - <text>page 3, rev 5</text> - </revision> -</page> -</mediawiki> diff --git a/tests/test-prefetch-previous.xml b/tests/test-prefetch-previous.xml deleted file mode 100644 index 95eb82dd..00000000 --- a/tests/test-prefetch-previous.xml +++ /dev/null @@ -1,57 +0,0 @@ -<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="en"> -<siteinfo> - <sitename>DemoWiki</sitename> - <base>http://example.com/wiki/Main_Page</base> - <generator>MediaWiki 1.5.0</generator> - <case>first-letter</case> - <namespaces> - <namespace key="-2">Media</namespace> - <namespace key="-1">Special</namespace> - <namespace key="0"></namespace> - <namespace key="1">Talk</namespace> - <namespace key="2">User</namespace> - <namespace key="3">User talk</namespace> - <namespace key="4">DemoWiki</namespace> - <namespace key="5">DemoWIki talk</namespace> - <namespace key="6">Image</namespace> - <namespace key="7">Image talk</namespace> - <namespace key="8">MediaWiki</namespace> - <namespace key="9">MediaWiki talk</namespace> - <namespace key="10">Template</namespace> - <namespace key="11">Template talk</namespace> - <namespace key="12">Help</namespace> - <namespace key="13">Help talk</namespace> - <namespace key="14">Category</namespace> - <namespace key="15">Category talk</namespace> - </namespaces> -</siteinfo> -<page> - <title>First page</title> - <id>1</id> - <revision> - <id>1</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 1, rev 1</comment> - <text>page 1, rev 1</text> - </revision> - <revision> - <id>2</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 1, rev 2</comment> - <text>page 1, rev 2</text> - </revision> -</page> -<page> - <title>Second page</title> - <id>2</id> - <revision> - <id>3</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 2, rev 3</comment> - <text>page 2, rev 3</text> - </revision> -</page> -</mediawiki> diff --git a/tests/test-prefetch-stub.xml b/tests/test-prefetch-stub.xml deleted file mode 100644 index 59d43d2f..00000000 --- a/tests/test-prefetch-stub.xml +++ /dev/null @@ -1,75 +0,0 @@ -<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/ http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="en"> -<siteinfo> - <sitename>DemoWiki</sitename> - <base>http://example.com/wiki/Main_Page</base> - <generator>MediaWiki 1.5.0</generator> - <case>first-letter</case> - <namespaces> - <namespace key="-2">Media</namespace> - <namespace key="-1">Special</namespace> - <namespace key="0"></namespace> - <namespace key="1">Talk</namespace> - <namespace key="2">User</namespace> - <namespace key="3">User talk</namespace> - <namespace key="4">DemoWiki</namespace> - <namespace key="5">DemoWIki talk</namespace> - <namespace key="6">Image</namespace> - <namespace key="7">Image talk</namespace> - <namespace key="8">MediaWiki</namespace> - <namespace key="9">MediaWiki talk</namespace> - <namespace key="10">Template</namespace> - <namespace key="11">Template talk</namespace> - <namespace key="12">Help</namespace> - <namespace key="13">Help talk</namespace> - <namespace key="14">Category</namespace> - <namespace key="15">Category talk</namespace> - </namespaces> -</siteinfo> -<page> - <title>First page</title> - <id>1</id> - <revision> - <id>1</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 1, rev 1</comment> - <text id="1" /> - </revision> - <revision> - <id>2</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 1, rev 2</comment> - <text id="2" /> - </revision> - <revision> - <id>4</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 1, rev 4</comment> - <text id="4" /> - </revision> -</page> -<page> - <title>Second page</title> - <id>2</id> - <revision> - <id>3</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 2, rev 3</comment> - <text id="3" /> - </revision> -</page> -<page> - <title>Third page</title> - <id>3</id> - <revision> - <id>5</id> - <timestamp>2001-01-15T12:00:00Z</timestamp> - <contributor><ip>10.0.0.1</ip></contributor> - <comment>page 3, rev 5</comment> - <text id="5" /> - </revision> -</page> -</mediawiki> |