/**
  * @covers Jgut\Slim\Middleware\DoctrineCacheFactory::configureCache
  * @covers Jgut\Slim\Middleware\DoctrineCacheFactory::configureRedisCache
  */
 public function testRedisCacheConfiguration()
 {
     if (!extension_loaded('redis')) {
         $this->setExpectedException('\\BadMethodCallException', 'RedisCache configured but module \'redis\' not loaded.');
     }
     $this->assertInstanceOf('Doctrine\\Common\\Cache\\RedisCache', DoctrineCacheFactory::configureCache(['type' => 'redis', 'host' => '127.0.0.1', 'port' => 6379]));
 }
 /**
  * Set up Doctrine Entity Manager Slim service
  *
  * @throws \RuntimeException
  */
 public function setup()
 {
     $app = $this->getApplication();
     $options = $app->config('doctrine');
     if (is_array($options)) {
         $this->setOptions($this->options, $options);
     }
     $proxyDir = $this->getOption('proxy_path');
     $cache = DoctrineCacheFactory::configureCache($this->getOption('cache_driver'));
     $config = Setup::createConfiguration(!!$app->config('debug'), $proxyDir, $cache);
     $config->setNamingStrategy(new UnderscoreNamingStrategy());
     $this->setupAnnotationMetadata();
     if (!$this->setupMetadataDriver($config)) {
         throw new \RuntimeException('No Metadata Driver defined');
     }
     $config->setAutoGenerateProxyClasses($this->getOption('auto_generate_proxies', true) == true);
     $connection = $this->getOption('connection');
     $app->container->singleton('entityManager', function () use($connection, $config) {
         return EntityManager::create($connection, $config);
     });
 }