Exemplo n.º 1
0
 public function testListKeys()
 {
     $response = new ListKeysResponse();
     $command = ListKeys::builder()->withNamespace($this->namespace)->withTimeout(90)->build();
     $response->iterator = new \ArrayIterator([new \ArrayIterator(['key1', 'key2']), new \ArrayIterator(['key3', 'key4'])]);
     $this->adapter->expects($this->once())->method('send')->will($this->returnValue($response));
     $result = $this->client->execute($command);
     $iterator = $result->getIterator();
     $this->assertInstanceOf('Riak\\Client\\Command\\Kv\\Response\\ListKeysResponse', $result);
     $this->assertInstanceOf('Iterator', $iterator);
 }
Exemplo n.º 2
0
 public function testListKeys()
 {
     $key = uniqid();
     $object = new RiakObject();
     $namespace = new RiakNamespace('default', 'bucket');
     $location = new RiakLocation($namespace, $key);
     $object->setValue('[1,1,1]');
     $object->setContentType('application/json');
     $this->client->execute(StoreValue::builder($location, $object)->withPw(RiakOption::ALL)->withW(RiakOption::ALL)->withReturnBody(true)->build());
     $command = ListKeys::builder($namespace)->withNamespace($namespace)->build();
     $result = $this->client->execute($command);
     $iterator = $result->getIterator();
     $locations = [];
     $this->assertInternalType('array', $locations);
     $this->assertInstanceOf('Iterator', $iterator);
     $this->assertInstanceOf('Riak\\Client\\Command\\Kv\\Response\\ListKeysResponse', $result);
     foreach ($result->getLocations() as $location) {
         $locations[$location->getKey()] = $location;
     }
     $this->assertArrayHasKey($key, $locations);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\RiakLocation', $locations[$key]);
     $this->assertEquals($namespace, $locations[$key]->getNamespace());
     $this->assertEquals($key, $locations[$key]->getKey());
 }