From: Ævar Arnfjörð Bjarmason Date: Sat, 6 Feb 2010 15:57:51 +0000 (+0000) Subject: Add a `make tap' target which runs the tests with `prove' and `phpunit --tap' X-Git-Tag: 1.31.0-rc.0~37902 X-Git-Url: https://git.cyclocoop.org/%28%28?a=commitdiff_plain;h=bbc4e95775842a75526be3cee83e5bb76b30beb9;p=lhc%2Fweb%2Fwiklou.git Add a `make tap' target which runs the tests with `prove' and `phpunit --tap' Also rename files so that all *Test*.php files are real test cases and not just skeletons used for setup, those are now called *Setup*.php. --- diff --git a/maintenance/tests/Makefile b/maintenance/tests/Makefile index 545a8b1962..5c8139485d 100644 --- a/maintenance/tests/Makefile +++ b/maintenance/tests/Makefile @@ -1,11 +1,17 @@ .PHONY: help test all test: phpunit + +tap: + prove -e 'phpunit --tap' *Test*.php + install: pear channel-discover pear.phpunit.de pear install phpunit/PHPUnit + help: # Options: # test (default) Run the unit tests + # tap Run the tests individually through Test::Harness's prove(1) # install Install PHPUnit from phpunit.de # help You're looking at it! diff --git a/maintenance/tests/MediaWikiAPITest.php b/maintenance/tests/MediaWikiAPITest.php index a08a9c97ae..045ec418ed 100644 --- a/maintenance/tests/MediaWikiAPITest.php +++ b/maintenance/tests/MediaWikiAPITest.php @@ -1,8 +1,8 @@ markTestIncomplete('This test needs $wgServerName and $wgServer to '. + 'be set in LocalSettings.php'); + } + self::$apiUrl = $wgServer.$wgScriptPath."/api".$wgScriptExtension; + + $wgMemc = new FakeMemCachedClient; + $wgContLang = Language::factory( 'en' ); + $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' ); + self::setupUser(); + } + + static function setupUser() { + if ( self::$user == NULL ) { + self::$userName = "Useruser"; + self::$passWord = User::randomPassword(); + + self::$user = User::newFromName(self::$userName); + if ( !self::$user->getID() ) { + self::$user = User::createNew(self::$userName, array( + "password" => self::$passWord, + "email" => "test@example.com", + "real_name" => "Test User")); + } else { + self::$user->setPassword(self::$passWord); + } + self::$user->saveSettings(); + } + } +} diff --git a/maintenance/tests/MediaWikiAPI_TestCase.php b/maintenance/tests/MediaWikiAPI_TestCase.php deleted file mode 100644 index e00e79b17a..0000000000 --- a/maintenance/tests/MediaWikiAPI_TestCase.php +++ /dev/null @@ -1,42 +0,0 @@ -markTestIncomplete('This test needs $wgServerName and $wgServer to '. - 'be set in LocalSettings.php'); - } - self::$apiUrl = $wgServer.$wgScriptPath."/api".$wgScriptExtension; - - $wgMemc = new FakeMemCachedClient; - $wgContLang = Language::factory( 'en' ); - $wgAuth = new StubObject( 'wgAuth', 'AuthPlugin' ); - self::setupUser(); - } - - static function setupUser() { - if ( self::$user == NULL ) { - self::$userName = "Useruser"; - self::$passWord = User::randomPassword(); - - self::$user = User::newFromName(self::$userName); - if ( !self::$user->getID() ) { - self::$user = User::createNew(self::$userName, array( - "password" => self::$passWord, - "email" => "test@example.com", - "real_name" => "Test User")); - } else { - self::$user->setPassword(self::$passWord); - } - self::$user->saveSettings(); - } - } -} diff --git a/maintenance/tests/MediaWiki_Setup.php b/maintenance/tests/MediaWiki_Setup.php new file mode 100644 index 0000000000..da42893c8c --- /dev/null +++ b/maintenance/tests/MediaWiki_Setup.php @@ -0,0 +1,53 @@ +markTestIncomplete("This test requires DB admin user credentials."); + $wgDBprefix = 'parsertest_'; + + $db = new DatabaseMysql( + $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/maintenance/tests/MediaWiki_TestCase.php b/maintenance/tests/MediaWiki_TestCase.php deleted file mode 100644 index 3e6b40acdf..0000000000 --- a/maintenance/tests/MediaWiki_TestCase.php +++ /dev/null @@ -1,53 +0,0 @@ -markTestIncomplete("This test requires DB admin user credentials."); - $wgDBprefix = 'parsertest_'; - - $db = new DatabaseMysql( - $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/maintenance/tests/SearchEngineTest.php b/maintenance/tests/SearchEngineTest.php index dc5023f456..dd3367a9f3 100644 --- a/maintenance/tests/SearchEngineTest.php +++ b/maintenance/tests/SearchEngineTest.php @@ -1,11 +1,11 @@