private static $dbSetup = false;
private static $oldTablePrefix = false;
+ /**
+ * Original value of PHP's error_reporting setting.
+ *
+ * @var int
+ */
+ private $phpErrorLevel;
+
/**
* Holds the paths of temporary files/directories created through getNewTempFile,
* and getNewTempDirectory
protected function getNewTempFile() {
$fname = tempnam( wfTempDir(), 'MW_PHPUnit_' . get_class( $this ) . '_' );
$this->tmpfiles[] = $fname;
+
return $fname;
}
// where temporary directory creation is bundled and can be improved
unlink( $fname );
$this->assertTrue( wfMkdirParents( $fname ) );
+
return $fname;
}
parent::setUp();
$this->called['setUp'] = 1;
+ $this->phpErrorLevel = intval( ini_get( 'error_reporting' ) );
+
/*
- //@todo: global variables to restore for *every* test
+ // @todo global variables to restore for *every* test
array(
'wgLang',
'wgContLang',
}
$this->mwGlobals = array();
+ $phpErrorLevel = intval( ini_get( 'error_reporting' ) );
+
+ if ( $phpErrorLevel !== $this->phpErrorLevel ) {
+ ini_set( 'error_reporting', $this->phpErrorLevel );
+
+ $oldHex = strtoupper( dechex( $this->phpErrorLevel ) );
+ $newHex = strtoupper( dechex( $phpErrorLevel ) );
+ $message = "PHP error_reporting setting was left dirty: was 0x$oldHex before test, 0x$newHex after test!";
+
+ $this->fail( $message );
+ }
+
parent::tearDown();
wfProfileOut( __METHOD__ );
}
* 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
'page_touched' => $this->db->timestamp(),
'page_latest' => 0,
'page_len' => 0 ), __METHOD__, array( 'IGNORE' ) );
-
}
User::resetIdByNameCache();
$user->saveSettings();
}
-
//Make 1 page with 1 revision
$page = WikiPage::factory( Title::newFromText( 'UTPage' ) );
if ( !$page->getId() == 0 ) {
* 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
*/
if ( ( $db->getType() == 'oracle' || !self::$useTemporaryTables ) && self::$reuseDB ) {
CloneDatabase::changePrefix( $prefix );
+
return;
} else {
$dbClone->cloneTableStructure();
private static function unprefixTable( $tableName ) {
global $wgDBprefix;
+
return substr( $tableName, strlen( $wgDBprefix ) );
}
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
unset( $tables['searchindex_segments'] );
$tables = array_flip( $tables );
}
+
return $tables;
}
if ( isset( MediaWikiPHPUnitCommand::$additionalOptions[$offset] ) ) {
return MediaWikiPHPUnitCommand::$additionalOptions[$offset];
}
-
}
public function setCliArg( $offset, $value ) {
MediaWikiPHPUnitCommand::$additionalOptions[$offset] = $value;
-
}
/**
}
/**
- * 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
) {
$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!" );
}
if ( !$loaded ) {
$this->markTestSkipped( "PHP extension '$extName' is not loaded, skipping." );
}
+
return $loaded;
}
* the provided code.
*
* @since 1.21
+ * @deprecated since 1.22 Use setExpectedException
*
* @param callable $code
* @param string $expected
$this->assertInstanceOf( $expected, $pokemons, $message );
}
-
}