summaryrefslogtreecommitdiff
path: root/tests/phpunit/MediaWikiTestCase.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
committerPierre Schmitz <pierre@archlinux.de>2013-12-08 09:55:49 +0100
commit4ac9fa081a7c045f6a9f1cfc529d82423f485b2e (patch)
treeaf68743f2f4a47d13f2b0eb05f5c4aaf86d8ea37 /tests/phpunit/MediaWikiTestCase.php
parentaf4da56f1ad4d3ef7b06557bae365da2ea27a897 (diff)
Update to MediaWiki 1.22.0
Diffstat (limited to 'tests/phpunit/MediaWikiTestCase.php')
-rw-r--r--tests/phpunit/MediaWikiTestCase.php32
1 files changed, 21 insertions, 11 deletions
diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php
index 7e6e0ab8..6ce78b56 100644
--- a/tests/phpunit/MediaWikiTestCase.php
+++ b/tests/phpunit/MediaWikiTestCase.php
@@ -64,7 +64,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
'oracle'
);
- function __construct( $name = null, array $data = array(), $dataName = '' ) {
+ function __construct( $name = null, array $data = array(), $dataName = '' ) {
parent::__construct( $name, $data, $dataName );
$this->backupGlobals = false;
@@ -137,6 +137,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
protected function getNewTempFile() {
$fname = tempnam( wfTempDir(), 'MW_PHPUnit_' . get_class( $this ) . '_' );
$this->tmpfiles[] = $fname;
+
return $fname;
}
@@ -158,6 +159,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
// where temporary directory creation is bundled and can be improved
unlink( $fname );
$this->assertTrue( wfMkdirParents( $fname ) );
+
return $fname;
}
@@ -171,7 +173,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
$this->called['setUp'] = 1;
/*
- //@todo: global variables to restore for *every* test
+ // @todo global variables to restore for *every* test
array(
'wgLang',
'wgContLang',
@@ -348,7 +350,8 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
* Stub. If a test needs to add additional data to the database, it should
* implement this method and do so
*/
- function addDBData() {}
+ function addDBData() {
+ }
private function addCoreDBData() {
# disabled for performance
@@ -377,7 +380,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
'page_touched' => $this->db->timestamp(),
'page_latest' => 0,
'page_len' => 0 ), __METHOD__, array( 'IGNORE' ) );
-
}
User::resetIdByNameCache();
@@ -394,7 +396,6 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
$user->saveSettings();
}
-
//Make 1 page with 1 revision
$page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
if ( !$page->getId() == 0 ) {
@@ -438,7 +439,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
* even if using different parameters.
*
* @param DatabaseBase $db The database connection
- * @param String $prefix The prefix to use for the new table set (aka schema).
+ * @param String $prefix The prefix to use for the new table set (aka schema).
*
* @throws MWException if the database table prefix is already $prefix
*/
@@ -461,6 +462,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
if ( ( $db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
CloneDatabase::changePrefix( $prefix );
+
return;
} else {
$dbClone->cloneTableStructure();
@@ -523,6 +525,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
private static function unprefixTable( $tableName ) {
global $wgDBprefix;
+
return substr( $tableName, strlen( $wgDBprefix ) );
}
@@ -534,6 +537,12 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
global $wgDBprefix;
$tables = $db->listTables( $wgDBprefix, __METHOD__ );
+
+ if ( $db->getType() === 'mysql' ) {
+ # bug 43571: cannot clone VIEWs under MySQL
+ $views = $db->listViews( $wgDBprefix, __METHOD__ );
+ $tables = array_diff( $tables, $views );
+ }
$tables = array_map( array( __CLASS__, 'unprefixTable' ), $tables );
// Don't duplicate test tables from the previous fataled run
@@ -547,6 +556,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
unset( $tables['searchindex_segments'] );
$tables = array_flip( $tables );
}
+
return $tables;
}
@@ -561,13 +571,11 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
if ( isset( MediaWikiPHPUnitCommand::$additionalOptions[$offset] ) ) {
return MediaWikiPHPUnitCommand::$additionalOptions[$offset];
}
-
}
public function setCliArg( $offset, $value ) {
MediaWikiPHPUnitCommand::$additionalOptions[$offset] = $value;
-
}
/**
@@ -775,7 +783,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
}
/**
- * Returns true iff the given namespace defaults to Wikitext
+ * Returns true if the given namespace defaults to Wikitext
* according to $wgNamespaceContentModels
*
* @param int $ns The namespace ID to check
@@ -839,12 +847,13 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
) {
$wikitextNS = $ns;
+
return $wikitextNS;
}
}
// give up
- // @todo: Inside a test, we could skip the test as incomplete.
+ // @todo Inside a test, we could skip the test as incomplete.
// But frequently, this is used in fixture setup.
throw new MWException( "No namespace defaults to wikitext!" );
}
@@ -906,6 +915,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
if ( !$loaded ) {
$this->markTestSkipped( "PHP extension '$extName' is not loaded, skipping." );
}
+
return $loaded;
}
@@ -914,6 +924,7 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
* the provided code.
*
* @since 1.21
+ * @deprecated since 1.22 Use setExpectedException
*
* @param callable $code
* @param string $expected
@@ -934,5 +945,4 @@ abstract class MediaWikiTestCase extends PHPUnit_Framework_TestCase {
$this->assertInstanceOf( $expected, $pokemons, $message );
}
-
}