public function testHasZone() { $site = $this->getMockSite(); CM_Config::get()->CM_Adprovider->enabled = true; CM_Config::get()->CM_Adprovider->zones = array('foo' => array('adapter' => 'CM_AdproviderAdapter_Nonexistent')); $adprovider = new CM_Adprovider(); $this->assertSame(true, $adprovider->hasZone($site, 'foo')); $this->assertSame(false, $adprovider->hasZone($site, 'bar')); }
public function testGetHtmlInvalidAdapter() { $site = $this->getMockSite(); CM_Config::get()->CM_Adprovider->enabled = true; CM_Config::get()->CM_Adprovider->zones = array('foo' => array('adapter' => 'CM_AdproviderAdapter_Nonexistent')); $adprovider = new CM_Adprovider(); try { $adprovider->getHtml($site, 'foo'); $this->fail('No exception for invalid ad adapter'); } catch (CM_Exception_Invalid $e) { $this->assertContains('Invalid ad adapter', $e->getMessage()); } }
/** * @return CM_Adprovider */ public static function getInstance() { if (!self::$_instance) { self::$_instance = new self(); } return self::$_instance; }
/** * @param array $params * @param Smarty_Internal_Template $template * @return string */ function smarty_function_advertisement(array $params, Smarty_Internal_Template $template) { if (!isset($params['zone'])) { trigger_error('Param `zone` missing.'); } /** @var CM_Frontend_Render $render */ $render = $template->smarty->getTemplateVars('render'); $variables = isset($params['variables']) ? $params['variables'] : null; return '<div class="advertisement">' . CM_Adprovider::getInstance()->getHtml($render->getSite(), $params['zone'], $variables) . '</div>'; }