Exemplo n.º 1
0
 public function create(array $params)
 {
     if (!$this->isValidParams($params)) {
         throw new InvalidCacheConfig();
     }
     $memcached = new \Memcached();
     $memcached->addServer($params['host'], $params['port']);
     return $memcached;
 }
 /**
  * @covers Dafiti\Silex\Cache\Factory\Memcached::create
  * @covers Dafiti\Silex\Cache\Factory\Memcached::isValidParams
  * @covers Dafiti\Silex\Cache\Factory\AbstractFactory::__construct
  */
 public function testCreateShouldReturnMemcachedInstance()
 {
     if (!extension_loaded(Memcached::MODULE_NAME)) {
         $this->markTestSkipped('Memcached Module Is Not Installed');
         return;
     }
     $params = ['host' => '127.0.0', 'port' => 11211];
     $factory = new Memcached();
     $result = $factory->create($params);
     $this->assertInstanceOf('\\Memcached', $result);
 }