From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- demos/time-tracker/tests/unit/BaseTestCase.php | 126 ++++++++++++------------- 1 file changed, 63 insertions(+), 63 deletions(-) (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 index d72cbc5c..10df400f 100644 --- a/demos/time-tracker/tests/unit/BaseTestCase.php +++ b/demos/time-tracker/tests/unit/BaseTestCase.php @@ -1,64 +1,64 @@ -sqlmap = $app->getModule('daos')->getClient(); - } - - - function flushDatabase() - { - $conn = $this->sqlmap->getDbConnection(); - $find = 'sqlite:protected'; - if(is_int(strpos($conn->getConnectionString(),$find))) - $conn->ConnectionString = str_replace($find, 'sqlite:../protected', $conn->ConnectionString); - $conn->setActive(false); - $conn->setActive(true); - switch(strtolower($conn->getDriverName())) - { - case 'mysql': - return $this->flushMySQLDatabase(); - case 'sqlite': - return $this->flushSQLiteDatabase(); - } - } - - function flushSQLiteDatabase() - { - $conn = $this->sqlmap->getDbConnection(); - $file = str_replace('sqlite:','',$conn->getConnectionString()); - $backup = $file.'.bak'; - copy($backup, $file); - } - - function flushMySQLDatabase() - { - $conn = $this->sqlmap->getDbConnection(); - $file = Prado::getPathOfNamespace('Application.App_Data.MySQL4.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->createCommand($line)->execute(); - } - } -} +sqlmap = $app->getModule('daos')->getClient(); + } + + + function flushDatabase() + { + $conn = $this->sqlmap->getDbConnection(); + $find = 'sqlite:protected'; + if(is_int(strpos($conn->getConnectionString(),$find))) + $conn->ConnectionString = str_replace($find, 'sqlite:../protected', $conn->ConnectionString); + $conn->setActive(false); + $conn->setActive(true); + switch(strtolower($conn->getDriverName())) + { + case 'mysql': + return $this->flushMySQLDatabase(); + case 'sqlite': + return $this->flushSQLiteDatabase(); + } + } + + function flushSQLiteDatabase() + { + $conn = $this->sqlmap->getDbConnection(); + $file = str_replace('sqlite:','',$conn->getConnectionString()); + $backup = $file.'.bak'; + copy($backup, $file); + } + + function flushMySQLDatabase() + { + $conn = $this->sqlmap->getDbConnection(); + $file = Prado::getPathOfNamespace('Application.App_Data.MySQL4.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->createCommand($line)->execute(); + } + } +} ?> \ No newline at end of file -- cgit v1.2.3