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();
 }
Пример #2
0
 public function testCards()
 {
     $this->open('/kwf/test/kwf_form_cards-real-models_test?id=1&testDb=' . Kwf_Test_SeparateDb::getDbName());
     $this->waitForConnections();
     $this->assertFalse($this->isVisible("//input[@name = 'firstname']"));
     $this->assertTrue($this->isVisible("//input[@name = 'lastname']"));
     $this->assertEquals('lasttest', $this->getValue("//input[@name = 'lastname']"));
     $this->type("//input[@name = 'lastname']", 'new last value');
     $this->click("//button[text()='" . trlKwf('Save') . "']");
     $this->waitForConnections();
     $this->open('/kwf/test/kwf_form_cards-real-models_test?id=1&testDb=' . Kwf_Test_SeparateDb::getDbName());
     $this->waitForConnections();
     $this->assertEquals('new last value', $this->getValue("//input[@name = 'lastname']"));
 }
Пример #3
0
 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);
     }
 }