public function init() { if ($this->_getParam('testDb')) { Kwf_Test_SeparateDb::setDbAndCreateCookie($this->_getParam('testDb')); } else { Kwf_Test_SeparateDb::setDbFromCookie(); } parent::init(); }
public function indexAction() { Zend_Registry::set('db', false); Kwf_Test_SeparateDb::setDbFromCookie(); // setzt es nur wenn es das cookie wirklich gibt //FnF models setzen damit tests nicht in echte tabellen schreiben Kwf_Component_Cache::setInstance(Kwf_Component_Cache::CACHE_BACKEND_FNF); Kwf_Component_Cache_Memory::setInstance(new Kwf_Component_Cache_MemoryBlackHole()); /* if (class_exists('APCIterator')) { $prefix = Kwf_Cache::getUniquePrefix(); apc_delete_file(new APCIterator('user', '#^'.$prefix.'#')); } else { apc_clear_cache('user'); } */ Kwf_Component_Data_Root::setComponentClass($this->_getParam('root')); Zend_Registry::set('testRootComponentClass', $this->_getParam('root')); $root = Kwf_Component_Data_Root::getInstance(); $root->setFilename('kwf/kwctest/' . $this->_getParam('root')); $url = $this->_getParam('url'); $urlParts = explode('/', $url); if (is_array($urlParts) && $urlParts[0] == 'media') { if (sizeof($urlParts) != 7) { throw new Kwf_Exception_NotFound(); } $class = $urlParts[1]; $id = $urlParts[2]; $type = $urlParts[3]; $checksum = $urlParts[4]; // time() wäre der 5er, wird aber nur wegen browsercache benötigt $filename = $urlParts[6]; if ($checksum != Kwf_Media::getChecksum($class, $id, $type, $filename)) { throw new Kwf_Exception_AccessDenied('Access to file not allowed.'); } Kwf_Media_Output::output(Kwf_Media::getOutput($class, $id, $type)); } if ($url == 'kwf/util/kwc/render') { if (isset($_REQUEST['url'])) { $_REQUEST['url'] = str_replace('/' . $root->filename, '', $_REQUEST['url']); } Kwf_Util_Component::dispatchRender(); } $domain = 'http://' . Zend_Registry::get('config')->server->domain; $data = $root->getPageByUrl($domain . Kwf_Setup::getBaseUrl() . '/' . $url, null); if (!$data) { throw new Kwf_Exception_NotFound(); } $root->setCurrentPage($data); $contentSender = Kwc_Abstract::getSetting($data->componentClass, 'contentSender'); $contentSender = new $contentSender($data); $contentSender->sendContent(true); Kwf_Benchmark::shutDown(); Kwf_Benchmark::output(); exit; }
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']")); }
public function getControllerClass(Zend_Controller_Request_Abstract $request) { $module = $request->getModuleName(); if ($module == 'component' && $request->getControllerName() == 'component' || $module == 'component_test' && $request->getControllerName() == 'component_test') { if ($module == 'component_test') { //FnF models setzen damit tests nicht in echte tabellen schreiben Kwf_Component_Cache::setInstance(Kwf_Component_Cache::CACHE_BACKEND_FNF); Kwf_Test_SeparateDb::setDbFromCookie(); // setzt es nur wenn es das cookie wirklich gibt if (!Kwf_Loader::isValidClass($request->getParam('root'))) { throw new Kwf_Exception_NotFound("Invalid root component"); } Kwf_Component_Data_Root::setComponentClass($request->getParam('root')); $root = Kwf_Component_Data_Root::getInstance(); $root->setFilename('kwf/kwctest/' . $request->getParam('root')); Kwf_Registry::get('acl')->getComponentAcl()->allowComponent('guest', null); //hick hack, für Kwf_Component_Abstract_Admin::getControllerUrl Zend_Registry::set('testRootComponentClass', $request->getParam('root')); } $class = $request->getParam('class'); $controller = $request->getParam('componentController'); $controller .= 'Controller'; if ($controller == 'IndexController') { $controller = 'Controller'; } if (($pos = strpos($class, '!')) !== false) { $controller = substr($class, $pos + 1) . 'Controller'; $class = substr($class, 0, $pos); } if (!in_array($class, Kwc_Abstract::getComponentClasses())) { //unknown component class return false; } $className = Kwc_Admin::getComponentClass($class, $controller); if (!$className) { return false; } class_exists($className); //trigger autoloader } else { $className = parent::getControllerClass($request); } return $className; }
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); } }
public function tearDown() { Kwf_Test_SeparateDb::restoreTestDb(); Kwf_Util_Check_Spam::setBackend(null); parent::tearDown(); }
public function tearDown() { Kwf_Test_SeparateDb::restoreTestDb(); parent::tearDown(); }
public function tearDown() { Kwf_Test_SeparateDb::restoreTestDb(); // macht das nur wenns eine gibt parent::tearDown(); }
public function tearDown() { ini_restore("session.gc_maxlifetime"); Kwf_Test_SeparateDb::restoreTestDb(); }