public function testFactoryWithAdapterAndLogger() { $adapter = new Adapter\FastCGI(); $logger = $this->getLogger(); $cachetool = CacheTool::factory($adapter, null, $logger); $this->assertCount(4, $cachetool->getProxies()); $this->assertSame($adapter, $cachetool->getAdapter()); $this->assertSame($logger, $cachetool->getLogger()); }
/** * @param InputInterface $input * @return ContainerInterface */ public function buildContainer(InputInterface $input) { if ($input->hasParameterOption('--cli')) { $this->config['adapter'] = 'cli'; } else { if ($input->hasParameterOption('--fcgi')) { $this->config['adapter'] = 'fastcgi'; $this->config['fastcgi'] = $input->getParameterOption('--fcgi'); } } if ($input->hasParameterOption('--tmp-dir') || $input->hasParameterOption('-t')) { $this->config['temp_dir'] = $input->getParameterOption('--tmp-dir') ?: $input->getParameterOption('-t'); } switch ($this->config['adapter']) { case 'cli': $adapter = new Cli(); break; case 'fastcgi': $adapter = new FastCGI($this->config['fastcgi']); break; default: throw new \RuntimeException("Adapter `{$this->config['adapter']}` is not one of cli or fastcgi"); } $cacheTool = CacheTool::factory($adapter, $this->config['temp_dir'], $this->logger); $container = new Container(); $container->set('cachetool', $cacheTool); $container->set('logger', $this->logger); return $container; }