public function testApplyViewHelpers() { $config = Bootstrap::getServiceManager()->get('Config'); $helperPluginManager = new HelperPluginManager(); $listener = new ViewHelperListener($this->layoutUpdater, $helperPluginManager, $config['con-layout']['view_helpers']); $mvcEvent = new \Zend\Mvc\MvcEvent(); $renderer = new PhpRenderer(); $renderer->setHelperPluginManager($helperPluginManager); $basePath = $helperPluginManager->get('basePath'); $basePath->setBasePath('/assets'); $basePathAssetPreparer = new BasePath($basePath); $listener->addAssetPreparer('headLink', $basePathAssetPreparer); /* @var $headLink HeadLink */ $headLink = $helperPluginManager->get('headLink'); /* @var $headScript HeadScript */ $headScript = $helperPluginManager->get('headScript'); /* @var $doctype \Zend\View\Helper\Doctype */ $doctype = $helperPluginManager->get('doctype'); /* @var $headTitle HeadTitle */ $headTitle = $helperPluginManager->get('headTitle'); /* @var $headMeta HeadMeta */ $headMeta = $helperPluginManager->get('headMeta'); $headMeta->setView($renderer); $listener->applyViewHelpers($mvcEvent); $expected = '<link href="/assets/css/test.css" media="screen" rel="stylesheet" type="text/css">' . PHP_EOL . '<link href="/assets/css/main.css" media="screen" rel="stylesheet" type="text/css">'; $this->assertEquals($expected, $headLink->toString()); $expected = '<script type="text/javascript" src="/js/jquery.min.js"></script>' . PHP_EOL . '<script type="text/javascript" src="/js/jquery-ui.min.js"></script>' . PHP_EOL . '<!--[if lt IE 9]><script type="text/javascript" src="/js/modernizr.js"></script><![endif]-->' . PHP_EOL . '<script type="text/javascript" src="/js/functions.js"></script>'; $this->assertEquals($expected, $headScript->toString()); $this->assertEquals('<!DOCTYPE html>', (string) $doctype); $headTitle->setSeparator(' | '); $expected = '<title>First | My Title | Another Title</title>'; $this->assertEquals($expected, $headTitle->toString()); $expected = '<meta charset="utf8">' . PHP_EOL . '<meta name="description" content="My description">' . PHP_EOL . '<meta name="keywords" content="keyword1, keyword2, keyword3">'; $this->assertEquals($expected, $headMeta->toString()); }
public function testRenderWithCachePre() { $renderer = clone $this->getBlockRenderer(); $em = clone Bootstrap::getServiceManager()->get('EventManager'); $renderer->setEventManager($em); $em->getSharedManager()->attach('ConLayout\\View\\Renderer\\BlockRenderer', 'render.pre', function ($e) { return 'cached'; }); $this->assertEquals('cached', $renderer->render($this->getViewModel())); $em->getSharedManager()->clearListeners('ConLayout\\View\\Renderer\\BlockRenderer'); }
public function setUp() { $eventManager = new EventManager(); $this->layoutUpdater = new LayoutUpdater(); $this->layoutUpdater->setEventManager($eventManager); $this->sm = Bootstrap::getServiceManager(); $this->em = $eventManager; $this->blockPool = new BlockPool(); $this->blockFactory = new BlockFactory([], new BlockManager(), $this->sm); $this->blocksGenerator = new BlocksGenerator($this->blockFactory, $this->blockPool); $this->layout = new Layout($this->layoutUpdater, $this->blockPool); $this->layout->attachGenerator(BlocksGenerator::NAME, $this->blocksGenerator); }
public function testInit() { $module = new Module(); $manager = Bootstrap::getServiceManager()->get('ModuleManager'); $module->init($manager); }
} protected static function initServiceManager() { $baseConfig = array('modules' => ['ConLayout'], 'module_listener_options' => array('module_paths' => [dirname(__DIR__)])); $config = $baseConfig; $serviceManager = new ServiceManager(); $serviceManager->setAllowOverride(true); $smConfig = new ServiceManagerConfig(); $smConfig->configureServiceManager($serviceManager); $serviceManager->setService('ApplicationConfig', $config); $serviceManager->get('ModuleManager')->loadModules(); static::$serviceManager = $serviceManager; } /** * * @return ServiceManager */ public static function getServiceManager() { return static::$serviceManager; } protected static function initAutoloader() { $vendorPath = __DIR__ . '/../vendor'; if (is_readable($vendorPath . '/autoload.php')) { include $vendorPath . '/autoload.php'; } } } Bootstrap::init();
public function setUp() { parent::setUp(); $this->strategy = Bootstrap::getServiceManager()->create('ConLayout\\View\\Strategy\\BlockRendererStrategy'); $this->em = Bootstrap::getServiceManager()->create('EventManager'); }