/**
* Sets dest to source and returns the original value of dest
* If source is NULL, it just returns the value, it doesn't set the variable
+ * If force is true, it will set the value even if source is NULL
*/
-function wfSetVar( &$dest, $source ) {
+function wfSetVar( &$dest, $source, $force = false ) {
$temp = $dest;
- if ( !is_null( $source ) ) {
+ if ( !is_null( $source ) || $force ) {
$dest = $source;
}
return $temp;
* Clone the table structure
*/
public function cloneTableStructure() {
+
+ sort($this->tablesToClone);
+
foreach( $this->tablesToClone as $tbl ) {
# Clean up from previous aborted run. So that table escaping
# works correctly across DB engines, we need to change the pre-
# fix back and forth so tableName() works right.
$this->changePrefix( $this->oldTablePrefix );
$oldTableName = $this->db->tableName( $tbl );
+
$this->changePrefix( $this->newTablePrefix );
$newTableName = $this->db->tableName( $tbl );
}
# Create new table
+ wfDebug( "Duplicating $oldTableName to $newTableName\n", __METHOD__ );
$this->db->duplicateTableStructure( $oldTableName, $newTableName, $this->useTemporaryTables );
+
}
}
}
function tablePrefix( $prefix = null ) {
- return wfSetVar( $this->mTablePrefix, $prefix );
+ return wfSetVar( $this->mTablePrefix, $prefix, true );
}
/**
$vars = get_object_vars($table);
$table = array_pop( $vars );
- if( empty( $prefix ) || strpos( $table, $prefix ) === 0 ) {
- $endArray[] = $table;
+ if( !$prefix || strpos( $table, $prefix ) === 0 ) {
+ if ( strpos( $table, 'sqlite_' ) !== 0 ) {
+ $endArray[] = $table;
+ }
+
}
}
protected $useTemporaryTables = true;
function __construct( $name = null, array $data = array(), $dataName = '' ) {
- if ($name !== null) {
- $this->setName($name);
- }
+ if ($name !== null) {
+ $this->setName($name);
+ }
- $this->data = $data;
- $this->dataName = $dataName;
+ $this->data = $data;
+ $this->dataName = $dataName;
}
function run( PHPUnit_Framework_TestResult $result = NULL ) {
- if( $this->needsDB() && !is_object( $this->dbClone ) ) {
+
+ if( $this->needsDB() ) {
+
+ $this->destroyDBCheck();
+
$this->initDB();
$this->addCoreDBData();
$this->addDBData();
}
+
parent::run( $result );
}
-
+
function __destruct() {
+ $this->destroyDBCheck();
+ }
+
+ function destroyDBCheck() {
if( is_object( $this->dbClone ) && $this->dbClone instanceof CloneDatabase ) {
$this->destroyDB();
}
# Anonymous user
$this->db->insert( 'user', array(
- 'user_id' => 0,
- 'user_name' => 'Anonymous' ) );
+ 'user_id' => 0,
+ 'user_name' => 'Anonymous' ) );
}
}