From c7d41e5bea4a5f96979a08da9cc9f79355edfe70 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 16 Jul 2006 06:19:36 +0000 Subject: Update Time Tracker demo. --- demos/time-tracker/tests/unit/BaseTestCase.php | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 demos/time-tracker/tests/unit/BaseTestCase.php (limited to 'demos/time-tracker/tests/unit/BaseTestCase.php') diff --git a/demos/time-tracker/tests/unit/BaseTestCase.php b/demos/time-tracker/tests/unit/BaseTestCase.php new file mode 100644 index 00000000..8ce3cca8 --- /dev/null +++ b/demos/time-tracker/tests/unit/BaseTestCase.php @@ -0,0 +1,35 @@ +sqlmap = $app->getModule('daos')->getConnection(); + } + + function flushDatabase() + { + $conn = $this->sqlmap->openConnection(); + $file = Prado::getPathOfNamespace('Application.App_Data.mysql-reset','.sql'); + if(is_file($file)) + $this->runScript($conn, $file); + else + throw new Exception('unable to find script file '.$file); + } + + protected function runScript($connection, $script) + { + $sql = file_get_contents($script); + $lines = explode(';', $sql); + foreach($lines as $line) + { + $line = trim($line); + if(strlen($line) > 0) + $connection->execute($line); + } + } +} +?> \ No newline at end of file -- cgit v1.2.3