public function testCanCacheMergedConfigFromGlob() { $options = new ListenerOptions(array('cache_dir' => $this->tmpdir, 'config_cache_enabled' => true)); $configListener = new ConfigListener($options); $configListener->addConfigGlobPath(__DIR__ . '/_files/good/*.{ini,php,xml}'); $moduleManager = $this->moduleManager; $moduleManager->setModules(array('SomeModule')); $moduleManager->events()->attachAggregate($configListener); $moduleManager->loadModules(); $configObjectFromGlob = $configListener->getMergedConfig(); // This time, don't add the glob path $configListener = new ConfigListener($options); $moduleManager = new Manager(array('SomeModule')); $moduleManager->events()->attach('loadModule.resolve', new ModuleResolverListener(), 1000); $moduleManager->events()->attachAggregate($configListener); $moduleManager->loadModules(); // Check if values from glob object and cache object are the same $configObjectFromCache = $configListener->getMergedConfig(); $this->assertNotNull($configObjectFromGlob->ini); $this->assertSame($configObjectFromGlob->ini, $configObjectFromCache->ini); $this->assertNotNull($configObjectFromGlob->php); $this->assertSame($configObjectFromGlob->php, $configObjectFromCache->php); $this->assertNotNull($configObjectFromGlob->xml); $this->assertSame($configObjectFromGlob->xml, $configObjectFromCache->xml); }
public function testCanMergeConfigFromGlob() { $configListener = new ConfigListener(); $configListener->addConfigGlobPath(__DIR__ . '/_files/good/*.{ini,json,php,xml,yml}'); $moduleManager = $this->moduleManager; $moduleManager->setModules(array('SomeModule')); $moduleManager->events()->attachAggregate($configListener); $moduleManager->loadModules(); $configObjectCheck = $configListener->getMergedConfig(); // Test as object $configObject = $configListener->getMergedConfig(); $this->assertSame(spl_object_hash($configObjectCheck), spl_object_hash($configObject)); $this->assertSame('loaded', $configObject->ini); $this->assertSame('loaded', $configObject->php); $this->assertSame('loaded', $configObject->json); $this->assertSame('loaded', $configObject->xml); $this->assertSame('loaded', $configObject->yml); // Test as array $config = $configListener->getMergedConfig(false); $this->assertSame('loaded', $config['ini']); $this->assertSame('loaded', $config['json']); $this->assertSame('loaded', $config['php']); $this->assertSame('loaded', $config['xml']); $this->assertSame('loaded', $config['yml']); }