Exemplo n.º 1
0
 public function testSiblingsWithUserMeta()
 {
     $key = uniqid();
     $object1 = new RiakObject();
     $object2 = new RiakObject();
     $location = new RiakLocation(new RiakNamespace('default', 'bucket'), $key);
     $object1->setContentType('application/json');
     $object1->setValue('{"name": "fabio"}');
     $object1->addMeta('group', 'guest');
     $object2->setContentType('application/json');
     $object2->setValue('{"name": "fabio"}');
     $object2->addMeta('group', 'admin');
     $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);
     $riakMeta1 = $riakObject1->getUserMeta();
     $riakMeta2 = $riakObject2->getUserMeta();
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Meta\\RiakUserMeta', $riakMeta1);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Meta\\RiakUserMeta', $riakMeta2);
     $this->assertCount(1, $riakMeta1);
     $this->assertTrue(isset($riakMeta1['group']));
     $this->assertTrue(isset($riakMeta2['group']));
     $this->assertEquals('guest', $riakMeta1['group']);
     $this->assertEquals('admin', $riakMeta2['group']);
     $this->client->execute(DeleteValue::builder($location)->build());
 }