Ejemplo n.º 1
0
    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 ModuleManager(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);
    }