/**
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param MemcachedAdapter $dummyMemchdAdapter
  * @param \Memcached $dummyMemchd
  */
 public function testPersistNonSerialized(KeyValueStore $kvs, MemcachedAdapter $dummyMemchdAdapter, \Memcached $dummyMemchd)
 {
     $dummyMemchd->shouldReceive('get')->with('key-e')->andReturn('value-e');
     $dummyMemchd->shouldReceive('getResultCode')->andReturn(\Memcached::RES_SUCCESS);
     $this->assertFalse($kvs->persist('key-e'));
 }
 public function testPersistError()
 {
     $memAdapterStub = \Mockery::mock('\\AdammBalogh\\KeyValueStore\\Adapter\\MemoryAdapter');
     $memAdapterStub->shouldReceive('persist')->andReturn(false);
     $repAdapter = new ReplicatorAdapter($memAdapterStub, new MemoryAdapter());
     $kvs = new KeyValueStore($repAdapter);
     $this->assertFalse($kvs->persist('key'));
 }
Ejemplo n.º 3
0
 /**
  * @expectedException \AdammBalogh\KeyValueStore\Exception\InternalException
  *
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param MockInterface $dummyAdapter
  */
 public function testPersistException(KeyValueStore $kvs, MockInterface $dummyAdapter)
 {
     $dummyAdapter->shouldReceive('persist')->andThrow('\\Exception');
     $kvs->persist('key');
 }
 /**
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param MemoryAdapter $memoryAdapter
  */
 public function testPersistExpired(KeyValueStore $kvs, MemoryAdapter $memoryAdapter)
 {
     $kvs->set('key', 555);
     $kvs->expire('key', 1);
     sleep(2);
     $this->assertFalse($kvs->persist('key'));
 }
 /**
  * @expectedException \Exception
  *
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param MemcacheAdapter $dummyMemchAdapter
  * @param \Memcache $dummyMemch
  */
 public function testPersistNonSerialized(KeyValueStore $kvs, MemcacheAdapter $dummyMemchAdapter, \Memcache $dummyMemch)
 {
     $dummyMemch->shouldReceive('get')->with('key-e')->andReturn('value-e');
     $kvs->persist('key-e');
 }
 /**
  * @dataProvider kvsProvider
  *
  * @param KeyValueStore $kvs
  * @param RedisAdapter $dummyRedisAdapter
  * @param RedisClient $dummyPredis
  */
 public function testPersist(KeyValueStore $kvs, RedisAdapter $dummyRedisAdapter, RedisClient $dummyPredis)
 {
     $dummyPredis->shouldReceive('persist')->with('key-e')->andReturn(1);
     $dummyPredis->shouldReceive('persist')->with('key-ne')->andReturn(0);
     $this->assertTrue($kvs->persist('key-e'));
     $this->assertFalse($kvs->persist('key-ne'));
 }