/** * @param \Enlight_View_Default $view * @param string $templatePath */ protected function extendsTemplate($view, $templatePath) { $version = $this->bootstrap->get('shop')->getTemplate()->getVersion(); if ($version >= 3) { $view->addTemplateDir($this->bootstrapPath . 'Views/responsive/'); } else { $view->addTemplateDir($this->bootstrapPath . 'Views/emotion/'); $view->extendsTemplate($templatePath); } }
public function testGetCacheId() { $this->view->loadTemplate('string:{block name="testBlock"}Content{$test}{/block}'); $this->view->setCacheId("123"); $this->view->addCacheId("456"); $this->assertArrayCount(2, explode('|', $this->view->getCacheId())); }
/** * Test case method * * @ticket 5268 */ public function testPostDispatch() { $request = $this->Request()->setModuleName('frontend')->setDispatched(true); $response = $this->Response(); $this->Plugin()->Config()->setAllowModifications()->set('tracking_code', 'TEST1234')->set('anonymize_ip', true); $view = new Enlight_View_Default(Shopware()->Template()); $view->loadTemplate('frontend/index/index.tpl'); $action = $this->getMock('Enlight_Controller_Action', null, array($request, $response)); $action->setView($view); $eventArgs = $this->createEventArgs()->setSubject($action); $e = null; try { $this->Plugin()->onPostDispatch($eventArgs); } catch (Exception $e) { } $this->assertNull($e); $this->assertEquals('TEST1234', $view->GoogleTrackingID); $this->assertTrue($view->GoogleAnonymizeIp); $this->assertContains('frontend/plugins/google/index.tpl', $view->Template()->getTemplateResource()); }
/** * Test case */ public function testViewCache() { $view = new Enlight_View_Default($this->engine); $view->loadTemplate('string:hello {uniqid()}'); $view->setCaching(true); $this->assertFalse($view->isCached()); $result = $view->render(); $view->loadTemplate('string:hello {uniqid()}'); $view->setCaching(true); $this->assertTrue($view->isCached()); $this->assertEquals($result, $view->render()); }
/** * Reset all instances, resources and init the internal view, template and front properties */ public function reset() { $app = Enlight_Application::Instance(); $this->resetRequest(); $this->resetResponse(); // Force the assignments to be cleared. Needed for some test cases if ($this->_view && $this->_view->hasTemplate()) { $this->_view->clearAssign(); } $this->_view = null; $this->_template = null; $this->_front = null; $app->Plugins()->reset(); //$app->Hooks()->resetHooks(); $app->Events()->reset(); //$app->Db()->getProfiler()->clear(); $app->Bootstrap()->resetResource('Plugins')->resetResource('Front')->resetResource('Router')->resetResource('System')->resetResource('Modules')->resetResource('Models'); // ->resetResource('Config') // ->resetResource('Shop'); // ->resetResource('Session') // ->resetResource('Auth'); $app->Bootstrap()->loadResource('Front'); $app->Bootstrap()->loadResource('Plugins'); }
/** * @param Enlight_View_Default $view */ protected function loadWidget(Enlight_View_Default $view) { $view->addTemplateDir(__DIR__ . '/Views/Common'); $version = Shopware()->Shop()->getTemplate()->getVersion(); if ($version >= 3) { $view->addTemplateDir(__DIR__ . '/Views/Responsive'); } else { $view->addTemplateDir(__DIR__ . '/Views/Emotion'); $view->extendsTemplate('frontend/checkout/index_darwinpricing.tpl'); } $widgetUrl = $this->getApiUrl('/widget'); $darwinPricingWidget = $this->loadAsynchronousJavascript($widgetUrl); $view->assign('darwinPricingWidget', $darwinPricingWidget); }
/** * Test case */ public function testViewFetch() { $view = new Enlight_View_Default($this->engine); $view->loadTemplate('string: '); $view->assign('test', 'success'); $this->assertEquals('success', $view->fetch('string:{$test}')); }
/** * extends the PayPal description * * @param View $view */ private function addTemplateVariables(View $view) { $newDescription = $this->bootstrap->Config()->get('paypalPlusDescription', ''); $newAdditionalDescription = $this->bootstrap->Config()->get('paypalPlusAdditionalDescription', ''); $payments = $view->getAssign('sPayments'); $validator = new APIValidator($this->restClient); if (empty($payments)) { return; } foreach ($payments as $key => $payment) { if ($payment['name'] !== 'paypal' || !$validator->isAPIAvailable()) { continue; } //Update the payment description $payments[$key]['description'] = $newDescription; $payments[$key]['additionaldescription'] = $payment['additionaldescription'] . $newAdditionalDescription; break; } $view->assign('sPayments', $payments); $user = $view->getAssign('sUserData'); if (!empty($user['additional']['payment']['name']) && $user['additional']['payment']['name'] === 'paypal' && $validator->isAPIAvailable()) { $user['additional']['payment']['description'] = $newDescription; $user['additional']['payment']['additionaldescription'] = $newAdditionalDescription; $view->assign('sUserData', $user); } if (method_exists($this->paypalBootstrap, 'getPayment')) { $payPalPaymentId = $this->paypalBootstrap->getPayment()->getId(); } else { //fallback for SwagPaymentPaypal version < 3.3.4 $payPalPaymentId = $this->paypalBootstrap->Payment()->getId(); } $view->assign('PayPalPaymentId', $payPalPaymentId); }