Ejemplo n.º 1
0
 public function testModuleLoaderListenerFunctionsAsAggregateListenerHasCache()
 {
     $options = new ListenerOptions(array('cache_dir' => $this->tmpdir, 'module_map_cache_key' => 'foo', 'module_map_cache_enabled' => true));
     file_put_contents($options->getModuleMapCacheFile(), '<?php return array();');
     $moduleLoaderListener = new ModuleLoaderListener($options);
     $moduleManager = $this->moduleManager;
     $this->assertEquals(1, count($moduleManager->getEventManager()->getListeners(ModuleEvent::EVENT_LOAD_MODULES)));
     $this->assertEquals(0, count($moduleManager->getEventManager()->getListeners(ModuleEvent::EVENT_LOAD_MODULES_POST)));
     $moduleLoaderListener->attach($moduleManager->getEventManager());
     $this->assertEquals(2, count($moduleManager->getEventManager()->getListeners(ModuleEvent::EVENT_LOAD_MODULES)));
     $this->assertEquals(0, count($moduleManager->getEventManager()->getListeners(ModuleEvent::EVENT_LOAD_MODULES_POST)));
 }
 /**
  * @param ServiceLocatorInterface $serviceLocator
  * @param Module $module
  * @return array
  */
 protected function getConfig(ServiceLocatorInterface $serviceLocator, Module $module)
 {
     // Load same configs as the ConfigListener would...
     $applicationConfiguration = $serviceLocator->get('ApplicationConfig');
     $listenerOptions = new ListenerOptions($applicationConfiguration['module_listener_options']);
     $configPaths = array_merge($this->getConfigPaths($listenerOptions->getConfigGlobPaths(), ConfigListener::GLOB_PATH), $this->getConfigPaths($listenerOptions->getConfigStaticPaths(), ConfigListener::STATIC_PATH));
     $config = $module->getConfig();
     $configs = array();
     foreach ($configPaths as $path) {
         $configs = array_merge($configs, $this->getConfigsByPath($path['path'], $path['type']));
     }
     foreach ($configs as $cfg) {
         $config = ArrayUtils::merge($config, $cfg);
     }
     return $config;
 }
Ejemplo n.º 3
0
 public function testSetExtraConfigThrowsInvalidArgumentException()
 {
     $this->setExpectedException('InvalidArgumentException');
     $options = new ListenerOptions();
     $options->setExtraConfig('asd');
 }
Ejemplo n.º 4
0
 public function testSetConfigGlobPathsThrowsInvalidArgumentException()
 {
     $this->setExpectedException('InvalidArgumentException');
     $options = new ListenerOptions;
     $options->setConfigGlobPaths('asd');
 }