/**
  * @expectedException \Exception
  *
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param MemcachedAdapter $dummyMemchdAdapter
  * @param \Memcached $dummyMemchd
  */
 public function testGetTtlNonSerialized(KeyValueStore $kvs, MemcachedAdapter $dummyMemchdAdapter, \Memcached $dummyMemchd)
 {
     $dummyMemchd->shouldReceive('get')->with('key-e')->andReturn('value-e');
     $dummyMemchd->shouldReceive('getResultCode')->andReturn(\Memcached::RES_SUCCESS);
     $kvs->getTtl('key-e');
 }
Ejemplo n.º 2
0
 /**
  * @return int
  *
  * @throws KeyNotFoundException
  */
 public function getAccessTokenTtl()
 {
     return $this->kvs->getTtl('access_token');
 }
 /**
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param ReplicatorAdapter $rep
  * @param MemoryAdapter $srcMem
  * @param MemoryAdapter $repMem
  */
 public function testGetTtl(KeyValueStore $kvs, ReplicatorAdapter $rep, MemoryAdapter $srcMem, MemoryAdapter $repMem)
 {
     $kvs->set('key', 'value');
     $kvs->expire('key', 5);
     $this->assertEquals(5, $kvs->getTtl('key'));
 }
Ejemplo n.º 4
0
 /**
  * @expectedException \AdammBalogh\KeyValueStore\Exception\InternalException
  *
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param MockInterface $dummyAdapter
  */
 public function testGetTtlException(KeyValueStore $kvs, MockInterface $dummyAdapter)
 {
     $dummyAdapter->shouldReceive('getTtl')->andThrow('\\Exception');
     $kvs->getTtl('key');
 }
 /**
  * @expectedException \Exception
  *
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param MemoryAdapter $memoryAdapter
  */
 public function testGetTtlError(KeyValueStore $kvs, MemoryAdapter $memoryAdapter)
 {
     $kvs->set('key', 555);
     $this->assertEquals(105, $kvs->getTtl('key'));
 }
 /**
  * @expectedException \Exception
  *
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param MemcacheAdapter $dummyMemchAdapter
  * @param \Memcache $dummyMemch
  */
 public function testGetTtlNonSerialized(KeyValueStore $kvs, MemcacheAdapter $dummyMemchAdapter, \Memcache $dummyMemch)
 {
     $dummyMemch->shouldReceive('get')->with('key-e')->andReturn('value-e');
     $kvs->getTtl('key-e');
 }
 /**
  * @expectedException \Exception
  *
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param RedisAdapter $dummyRedisAdapter
  * @param RedisClient $dummyPredis
  */
 public function testGetTtlNoExpire(KeyValueStore $kvs, RedisAdapter $dummyRedisAdapter, RedisClient $dummyPredis)
 {
     $dummyPredis->shouldReceive('ttl')->with('key-ne')->andReturn(-1);
     $kvs->getTtl('key-ne');
 }