Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public function has(AggregateIdInterface $id, $version)
 {
     if (!$this->redis->hexists(static::KEY_NAMESPACE, (string) $id)) {
         return false;
     }
     $snapshot = $this->serializer->deserialize($this->redis->hget(static::KEY_NAMESPACE, (string) $id), 'array', 'json');
     return $snapshot['version'] === $version;
 }
 /**
  * @param $id
  * @param $expectedDeserializedRedisData
  */
 protected function mockRedisHasAndGetData($id, $expectedDeserializedRedisData)
 {
     $this->client->hexists(RedisSnapshotAdapter::KEY_NAMESPACE, (string) $id)->willReturn(true)->shouldBeCalledTimes(1);
     $this->client->hget(RedisSnapshotAdapter::KEY_NAMESPACE, (string) $id)->willReturn('redis_data')->shouldBeCalledTimes(1);
     $this->serializer->deserialize('redis_data', 'array', 'json')->willReturn($expectedDeserializedRedisData);
 }
Esempio n. 3
0
 /**
  * @group redis-hashes
  */
 public function testHashGet()
 {
     $this->assertNull($this->client->hget('foo', 'bar'));
     $this->client->hset('foo', 'bar', 'hello');
     $this->assertEquals('hello', $this->client->hget('foo', 'bar'));
 }