summaryrefslogtreecommitdiff
path: root/demos/time-tracker/tests/unit/BaseTestCase.php
diff options
context:
space:
mode:
Diffstat (limited to 'demos/time-tracker/tests/unit/BaseTestCase.php')
-rw-r--r--demos/time-tracker/tests/unit/BaseTestCase.php24
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);