mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT: Added db-abstraction for test database creation and removal.
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@76345 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
e4efbcb78c
commit
392608b0fa
@ -225,9 +225,10 @@ class DatabaseAdmin extends Controller {
|
||||
* @todo Move this code into Database class, for DB abstraction
|
||||
*/
|
||||
function clearAllData() {
|
||||
$tables = DB::query("SHOW TABLES")->column();
|
||||
$tables = DB::getConn()->tableList();
|
||||
foreach($tables as $table) {
|
||||
DB::query("TRUNCATE \"$table\"");
|
||||
if(DB::getConn()->hasMethod('clearTable')) DB::getConn()->clearTable($table);
|
||||
else DB::query("TRUNCATE \"$table\"");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
if(self::using_temp_db()) {
|
||||
$dbConn = DB::getConn();
|
||||
$dbName = $dbConn->currentDatabase();
|
||||
if($dbName && DB::query("SHOW DATABASES LIKE '$dbName'")->value()) {
|
||||
if($dbName && DB::getConn()->databaseExists($dbName)) {
|
||||
// echo "Deleted temp database " . $dbConn->currentDatabase() . "\n";
|
||||
$dbConn->dropDatabase();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user