diff options
author | wei <> | 2006-07-28 12:32:01 +0000 |
---|---|---|
committer | wei <> | 2006-07-28 12:32:01 +0000 |
commit | 623447ffea7a49359c773a0bc3a851397885f319 (patch) | |
tree | 93676acdeea5697dd00fb10d0eb70948901b549e /demos/time-tracker/tests/unit/BaseTestCase.php | |
parent | fbf05a159bc1a688940c16dc304eaaf140188b01 (diff) |
Add sqlite support for time-tracker.
Diffstat (limited to 'demos/time-tracker/tests/unit/BaseTestCase.php')
-rw-r--r-- | demos/time-tracker/tests/unit/BaseTestCase.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/demos/time-tracker/tests/unit/BaseTestCase.php b/demos/time-tracker/tests/unit/BaseTestCase.php index 8ce3cca8..549229e3 100644 --- a/demos/time-tracker/tests/unit/BaseTestCase.php +++ b/demos/time-tracker/tests/unit/BaseTestCase.php @@ -1,5 +1,8 @@ <?php
+
+Prado::using('Application.App_Code.Dao.*');
+
class BaseTestCase extends UnitTestCase
{
protected $sqlmap;
@@ -10,9 +13,30 @@ class BaseTestCase extends UnitTestCase $this->sqlmap = $app->getModule('daos')->getConnection();
}
+
function flushDatabase()
{
$conn = $this->sqlmap->openConnection();
+ switch(strtolower($conn->getProvider()->getDriver()))
+ {
+ case 'mysql':
+ return $this->flushMySQLDatabase();
+ case 'sqlite':
+ return $this->flushSQLiteDatabase();
+ }
+ }
+
+ function flushSQLiteDatabase()
+ {
+ $conn = $this->sqlmap->openConnection();
+ $file = $conn->getProvider()->getHost();
+ $backup = $file.'.bak';
+ copy($backup, $file);
+ }
+
+ function flushMySQLDatabase()
+ {
+ $conn = $this->sqlmap->openConnection();
$file = Prado::getPathOfNamespace('Application.App_Data.mysql-reset','.sql');
if(is_file($file))
$this->runScript($conn, $file);
|