protected final function _process() { $filename = $this->_root->filename; Kwf_Events_ModelObserver::getInstance()->process(); Kwf_Component_Data_Root::reset(); $this->_root = Kwf_Component_Data_Root::getInstance(); $this->_root->setFilename($filename); }
public function testSerializeEn() { $c = $this->_root->getComponentById('root-en_directory_1'); $s = $c->kwfSerialize(); unset($c); Kwf_Component_Data_Root::reset(); $c = Kwf_Component_Data::kwfUnserialize($s); $this->assertEquals($c->componentId, 'root-en_directory_1'); }
public function tearDown() { Kwf_Events_ModelObserver::getInstance()->setSkipFnF(true); Kwf_Component_Data_Root::reset(); Kwf_Component_Cache::clearInstance(); Kwf_Model_Abstract::clearInstances(); Kwf_Events_Dispatcher::clearCache(); Kwf_Events_Subscriber::clearInstances(); Kwf_Component_PagesMetaModel::clearInstance(); Kwf_Trl::getInstance()->unsetTrlElements(); }
public function testAddPage() { $page = $this->_root->getComponentById(1); $page->render(true, true); Kwf_Component_Data_Root::reset(); $row = $this->_root->getGenerator('page')->getModel()->createRow(array('pos' => 3, 'visible' => true, 'name' => 'f5', 'filename' => 'f5', 'parent_id' => 'root', 'component' => 'empty', 'is_home' => false, 'device_visible' => 'onlyShowOnMobile', 'hide' => false, 'custom_filename' => null)); $row->save(); $this->_process(); $html = $page->render(true, true); $this->assertEquals(1, substr_count($html, 'hideOnMobile')); $this->assertEquals(1, substr_count($html, 'onlyShowOnMobile')); }
/** * Recursively duplicate components * * You need to call afterDuplicate afterwards! */ public static function duplicate(Kwf_Component_Data $source, Kwf_Component_Data $parentTarget, Zend_ProgressBar $progressBar = null) { $new = $source->generator->duplicateChild($source, $parentTarget, $progressBar); if (!$new) { throw new Kwf_Exception("Failed duplicating '{$source->componentId}'"); } Kwf_Component_Generator_Abstract::clearInstances(); Kwf_Component_Data_Root::reset(); //TODO: schöner wär ein flag bei den komponenten ob es diese fkt im admin //gibt und dann für alle admins aufrufen //ändern sobald es für mehrere benötigt wird Kwc_Root_TrlRoot_Chained_Admin::duplicated($source, $new); return $new; }
public function testCached() { Kwf_Benchmark::enable(); Kwf_Benchmark::reset(); $d = Kwf_Registry::get('testDomain'); $c = $this->_root->getPageByUrl("http://{$d}/foo", null); //uncached $this->assertEquals('1', $c->componentId); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('componentDatas')); $this->assertEquals(0, (int) Kwf_Benchmark::getCounterValue('unserialized componentDatas')); Kwf_Component_Data_Root::reset(); Kwf_Component_Data_Root::setComponentClass('Kwf_Component_Cache_UrlClearCache_Root'); $this->_root = Kwf_Component_Data_Root::getInstance(); Kwf_Benchmark::reset(); $c = $this->_root->getPageByUrl("http://{$d}/foo", null); //cached $this->assertEquals('1', $c->componentId); $this->assertEquals(0, (int) Kwf_Benchmark::getCounterValue('componentDatas')); $this->assertEquals(1, Kwf_Benchmark::getCounterValue('unserialized componentDatas')); }
protected function _afterSave() { parent::_afterSave(); Kwf_Component_Data_Root::reset(); Kwf_Component_Generator_Abstract::clearInstances(); }
private function _executeUpdatesAction($method) { $ret = true; foreach ($this->_updates as $update) { Kwf_Model_Abstract::clearInstances(); //wegen eventueller meta-data-caches die sich geändert haben Kwf_Component_Generator_Abstract::clearInstances(); Kwf_Component_Data_Root::reset(); if ($this->_progressBar && $method == 'update') { $this->_progressBar->next(1, $update->getUniqueName()); } $e = false; try { if (!$this->_verbose) { ob_start(); //update script should not output anything, if it still does discard it } $update->{$method}(); if (!$this->_verbose) { ob_end_clean(); } } catch (Exception $e) { if (!$this->_verbose) { ob_end_clean(); } if ($this->_debug) { throw $e; } $this->_errors[] = array('name' => $update->getUniqueName(), 'message' => $e->getMessage()); if ($this->_verbose) { echo "\n[31mError:[0m\n"; echo $e->getMessage() . "\n\n"; flush(); } $ret = false; } } return $ret; }
public function testHideInMenu() { $page = $this->_root->getComponentById(1); $html = $page->render(true, true); $this->assertEquals(2, substr_count($html, '<li')); $this->assertEquals(2, substr_count($html, 'f1')); $this->assertEquals(2, substr_count($html, 'f4')); Kwf_Component_Data_Root::reset(); $row = $this->_root->getGenerator('page')->getModel()->getRow(1); $row->hide = true; $row->save(); $this->_process(); $html = $page->render(true, true); $this->assertEquals(1, substr_count($html, '<li')); $this->assertEquals(2, substr_count($html, 'f4')); $row = $this->_root->getGenerator('page')->getModel()->getRow(1); $row->hide = false; $row->save(); $this->_process(); $html = $page->render(true, true); $this->assertEquals(2, substr_count($html, '<li')); $this->assertEquals(2, substr_count($html, 'f1')); $this->assertEquals(2, substr_count($html, 'f4')); }
public function testMakePageVisibleFromTop() { $this->_root->getComponentById('1')->render(true, true); $this->_root->getComponentById('3')->render(true, true); $this->_root->getComponentById('4')->render(true, true); Kwf_Component_Data_Root::reset(); $m = Kwf_Model_Abstract::getInstance('Kwf_Component_Cache_MenuHasContent_Category_PagesModel'); $row = $m->getRow(2); $row->visible = true; $row->save(); $this->_process(); $html = $this->_root->getComponentById('1')->render(true, true); $this->assertContains('menuTopHasContent', $html); $this->assertContains('menuMainHasContent', $html); $html = $this->_root->getComponentById('3')->render(true, true); $this->assertContains('menuTopHasContent', $html); $this->assertContains('menuMainHasContent', $html); $html = $this->_root->getComponentById('4')->render(true, true); $this->assertContains('menuTopHasContent', $html); $this->assertContains('menuMainHasContent', $html); }
public function testClearOutputCache() { $c = $this->_root->getComponentById('1600'); $this->assertEquals(Kwf_Media::DONT_HASH_TYPE_PREFIX . '{width}-76b7ff', $c->getComponent()->getBaseType()); Kwf_Media::clearCache('Kwc_Basic_Image_FixDimensionComponent', '1600', Kwf_Media::DONT_HASH_TYPE_PREFIX . '16-76b7ff'); Kwc_Basic_Image_FixDimensionComponent::$getMediaOutputCalled = 0; Kwf_Media::getOutput('Kwc_Basic_Image_FixDimensionComponent', '1600', Kwf_Media::DONT_HASH_TYPE_PREFIX . '16-76b7ff'); $this->assertEquals(1, Kwc_Basic_Image_FixDimensionComponent::$getMediaOutputCalled); Kwf_Media::getOutput('Kwc_Basic_Image_FixDimensionComponent', '1600', Kwf_Media::DONT_HASH_TYPE_PREFIX . '16-76b7ff'); $this->assertEquals(1, Kwc_Basic_Image_FixDimensionComponent::$getMediaOutputCalled); Kwf_Media::clearCache('Kwc_Basic_Image_FixDimensionComponent', '1600', Kwf_Media::DONT_HASH_TYPE_PREFIX . '16-76b7ff'); Kwf_Media::getOutput('Kwc_Basic_Image_FixDimensionComponent', '1600', Kwf_Media::DONT_HASH_TYPE_PREFIX . '16-76b7ff'); $this->assertEquals(2, Kwc_Basic_Image_FixDimensionComponent::$getMediaOutputCalled); $row = Kwf_Model_Abstract::getInstance('Kwc_Basic_Image_TestModel')->getRow('1600'); $row->kwf_upload_id = 2; $row->save(); Kwf_Events_ModelObserver::getInstance()->process(); Kwf_Component_Data_Root::reset(); Kwf_Media::getOutput('Kwc_Basic_Image_FixDimensionComponent', '1600', Kwf_Media::DONT_HASH_TYPE_PREFIX . '100-76b7ff'); $this->assertEquals(3, Kwc_Basic_Image_FixDimensionComponent::$getMediaOutputCalled); }