public function testCanSetDefaultListenerOptions() { $options = new ListenerOptions(array('cache_dir' => __DIR__)); $moduleManager = new Manager(array()); $moduleManager->setDefaultListenerOptions($options); $this->assertSame(__DIR__, $moduleManager->getDefaultListenerOptions()->cache_dir); }
public function testCanCacheMergedConfig() { $moduleManager = new Manager(array('SomeModule', 'ListenerTestModule')); $options = new ListenerOptions(array('cache_dir' => $this->tmpdir, 'config_cache_enabled' => true)); $moduleManager->setDefaultListenerOptions($options); $moduleManager->loadModules(); // This should cache the config $modules = $moduleManager->getLoadedModules(); $this->assertTrue($modules['ListenerTestModule']->getConfigCalled); // Now we check to make sure it uses the config and doesn't hit // the module objects getConfig() method(s) $moduleManager = new Manager(array('SomeModule', 'ListenerTestModule')); $moduleManager->setDefaultListenerOptions($options); $moduleManager->loadModules(); $modules = $moduleManager->getLoadedModules(); $this->assertFalse($modules['ListenerTestModule']->getConfigCalled); }
public function testGlobMergingHonorsProvidedEnvironment() { $moduleManager = new Manager(array('SomeModule')); $options = new ListenerOptions(array('application_environment' => 'testing')); $moduleManager->setDefaultListenerOptions($options); $configListener = $moduleManager->getConfigListener(); $configListener->addConfigGlobPaths(new ArrayObject(array(__DIR__ . '/_files/good/*.ini', __DIR__ . '/_files/good/*.json', __DIR__ . '/_files/good/*.php', __DIR__ . '/_files/good/*.xml', __DIR__ . '/_files/good/*.yml'))); $moduleManager->loadModules(); // Test as object $configObject = $moduleManager->getMergedConfig(); $this->assertSame('testing', $configObject->ini); $this->assertSame('testing', $configObject->php); $this->assertSame('testing', $configObject->json); $this->assertSame('testing', $configObject->xml); $this->assertSame('testing', $configObject->yml); }