/** * @dataProvider configProvider */ public function testLoadDriverConfiguration($config) { $container = new ContainerBuilder(); $container->setParameter('kernel.environment', 'test'); $extension = new TedivmStashExtension(); $extension->load(array($config), $container); $this->assertEquals($config['default_cache'], $container->getParameter('stash.default_cache')); $this->assertEquals(count($config['caches']), count($container->getParameter('stash.caches'))); $options = $container->getParameter('stash.caches.options'); foreach ($config['caches'] as $name => $cache) { $cacheoptions = $options[$name]; $this->assertArrayHasKey($name, $container->getParameter('stash.caches')); foreach (array('inMemory') as $item) { $value = isset($cache[$item]) ? $cache[$item] : true; $this->assertEquals($cacheoptions[$item], $value); } foreach (array('registerSessionHandler', 'registerDoctrineAdapter') as $item) { $value = isset($cache[$item]) ? $cache[$item] : false; $this->assertEquals($cacheoptions[$item], $value); } if (isset($cache['drivers'])) { foreach ($cache['drivers'] as $driver) { $driveroptions = $cache[$driver]; foreach ($driveroptions as $driveroptname => $driveroptvalue) { $this->assertEquals($driveroptvalue, $cacheoptions[$driver][$driveroptname]); } } } } }
/** * @dataProvider configProvider */ public function testLoadHandlerConfiguration($config) { $container = new ContainerBuilder(); $extension = new TedivmStashExtension(); $extension->load(array($config), $container); $this->assertEquals($config['default_cache'], $container->getParameter('stash.default_cache')); $this->assertEquals(count($config['caches']), count($container->getParameter('stash.caches'))); $options = $container->getParameter('stash.caches.options'); foreach ($config['caches'] as $name => $cache) { $cacheoptions = $options[$name]; $this->assertArrayHasKey($name, $container->getParameter('stash.caches')); foreach (array('registerDoctrineAdapter', 'inMemory') as $item) { $this->assertEquals($cache[$item], $cacheoptions[$item]); } foreach ($cache['handlers'] as $handler) { $handleroptions = $cache[$handler]; foreach ($handleroptions as $handleroptname => $handleroptvalue) { $this->assertEquals($handleroptvalue, $cacheoptions[$handler][$handleroptname]); } } } }