protected function initTestDb($bootstrapFile)
 {
     Kwf_Test_SeparateDb::createSeparateTestDb($bootstrapFile);
     $dbName = Kwf_Test_SeparateDb::getDbName();
     $this->createCookie('test_special_db=' . $dbName, 'path=/, max_age=60*5');
     Kwf_Registry::set('db', Kwf_Test::getTestDb($dbName));
     Kwf_Model_Abstract::clearInstances();
 }
 public function importAction()
 {
     Zend_Registry::set('db', Kwf_Test::getTestDb());
     $server = new Kwf_Srpc_Server();
     $server->setClass('Kwf_Model_DbWithConnection_ImportExport_Handler');
     $server->handle();
     exit;
 }
 public static function initForTests()
 {
     Kwf_Session::start();
     Kwf_Util_MemoryLimit::set(512);
     Kwf_Component_Data_Root::setComponentClass(false);
     Zend_Registry::set('db', Kwf_Test::getTestDb());
     set_time_limit(0);
     Kwf_Benchmark::disable();
 }
 public static function restoreTestDb()
 {
     $dbName = Kwf_Test_SeparateDb::getDbName();
     if ($dbName) {
         $testDb = Kwf_Test::getTestDb();
         // alte test-dbs löschen
         $testDatabases = $testDb->query('SHOW DATABASES')->fetchAll();
         foreach ($testDatabases as $testDatabase) {
             if (preg_match('/^test_[^_]+_([0-9]+)_[0-9]+_[^_]+$/', $testDatabase['Database'], $matches)) {
                 // test-db löschen wenn sie älter als 2 tage is
                 if ((int) $matches[1] < (int) date('Ymd', time() - 2 * 86400)) {
                     $testDb->query('DROP DATABASE ' . $testDatabase['Database']);
                 }
             }
         }
         $testDb->query('DROP DATABASE ' . $dbName);
         Kwf_Test_SeparateDb::$_dbName = null;
         Kwf_Registry::set('db', $testDb);
     }
 }