public function testObjectWithUserMeta()
 {
     $key = uniqid();
     $object = new RiakObject();
     $meta = new RiakUsermeta();
     $location = new RiakLocation(new RiakNamespace('default', 'bucket'), $key);
     $meta['key'] = 'other';
     $meta['meta'] = 'content';
     $meta['remove'] = 'other';
     $meta->remove('remove');
     $meta->put('key', 'value');
     $object->setContentType('application/json');
     $object->setValue('{"name": "fabio"}');
     $object->setUserMeta($meta);
     $store = StoreValue::builder($location, $object)->withReturnBody(true)->withPw(1)->withW(1)->build();
     $fetch = FetchValue::builder($location)->withNotFoundOk(true)->withR(1)->build();
     $this->client->execute($store);
     $result = $this->client->execute($fetch);
     $riakObject = $result->getValue();
     $riakMeta = $riakObject->getUserMeta();
     $this->assertFalse($result->getNotFound());
     $this->assertInstanceOf('Riak\\Client\\Command\\Kv\\Response\\FetchValueResponse', $result);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\Meta\\RiakUserMeta', $riakMeta);
     $this->assertInstanceOf('Riak\\Client\\Core\\Query\\RiakObject', $riakObject);
     $this->assertEquals('{"name": "fabio"}', $riakObject->getValue());
     $this->assertCount(2, $riakMeta);
     $this->assertTrue(isset($riakMeta['key']));
     $this->assertTrue(isset($riakMeta['meta']));
     $this->assertEquals('value', $riakMeta['key']);
     $this->assertEquals('content', $riakMeta['meta']);
     $this->assertEquals('value', $riakMeta->get('key'));
     $this->assertEquals('content', $riakMeta->get('meta'));
     $this->client->execute(DeleteValue::builder($location)->build());
 }
Example #2
0
 /**
  * @param string $key
  * @param mixed  $value
  */
 public function addMeta($key, $value)
 {
     if ($this->meta === null) {
         $this->meta = new RiakUsermeta();
     }
     $this->meta->put($key, $value);
 }