Exemplo n.º 1
0
 public function testSiblingsWithIndexes()
 {
     $key = uniqid();
     $object1 = new RiakObject();
     $object2 = new RiakObject();
     $location = new RiakLocation(new RiakNamespace('default', 'bucket'), $key);
     $object1->addIndex(new RiakIndexBin('group', ['guest']));
     $object1->setContentType('application/json');
     $object1->setValue('{"name": "fabio"}');
     $object2->addIndex(new RiakIndexBin('group', ['admin']));
     $object2->setContentType('application/json');
     $object2->setValue('{"name": "fabio"}');
     $this->client->execute(StoreValue::builder($location, $object1)->withW(3)->build());
     $this->client->execute(StoreValue::builder($location, $object2)->withW(3)->build());
     $result = $this->client->execute(FetchValue::builder($location)->withNotFoundOk(true)->withR(1)->build());
     $this->assertInstanceOf('Riak\\Client\\Command\\Kv\\Response\\FetchValueResponse', $result);
     $this->assertCount(2, $result->getValues());
     $riakObject1 = $result->getValues()->offsetGet(0);
     $riakObject2 = $result->getValues()->offsetGet(1);
     $riakIndexes1 = $riakObject1->getIndexes();
     $riakIndexes2 = $riakObject2->getIndexes();
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Index\\RiakIndexList', $riakIndexes1);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Index\\RiakIndexList', $riakIndexes2);
     $this->assertCount(1, $riakIndexes1);
     $this->assertTrue(isset($riakIndexes1['group']));
     $this->assertTrue(isset($riakIndexes2['group']));
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Index\\RiakIndexBin', $riakIndexes1['group']);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Index\\RiakIndexBin', $riakIndexes2['group']);
     $this->assertEquals('group', $riakIndexes1['group']->getName());
     $this->assertEquals('group', $riakIndexes2['group']->getName());
     $this->assertEquals(['guest'], $riakIndexes1['group']->getValues());
     $this->assertEquals(['admin'], $riakIndexes2['group']->getValues());
     $this->client->execute(DeleteValue::builder($location)->build());
 }