Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function toDomain(RiakObjectReference $reference)
 {
     $location = $reference->getLocation();
     $riakObject = $reference->getRiakObject();
     $type = $reference->getDomainObjectType();
     $domainObject = $this->toDomainObject($riakObject->getValue(), $type);
     $this->domainHydrator->setDomainObjectValues($domainObject, $riakObject, $location);
     return $domainObject;
 }
 public function testToDomain()
 {
     $riakObject = new RiakObject();
     $domainObject = new SimpleObject('[1,2,3]');
     $namespace = new RiakNamespace('type', 'bucket');
     $location = new RiakLocation($namespace, 'riak-key');
     $reference = new RiakObjectReference($riakObject, $location, SimpleObject::CLASS_NAME);
     $riakObject->setValue('{"value":[1,2,3]}');
     $this->instance->expects($this->once())->method('toDomainObject')->with($this->equalTo('{"value":[1,2,3]}'), $this->equalTo(SimpleObject::CLASS_NAME))->willReturn($domainObject);
     $this->hydrator->expects($this->once())->method('setDomainObjectValues')->with($this->equalTo($domainObject), $this->equalTo($riakObject), $this->equalTo($location));
     $this->assertSame($domainObject, $this->instance->toDomain($reference));
 }
 public function testHidrateRiakObject()
 {
     $riakObject = new RiakObject();
     $domainObject = new SimpleObject();
     $vClock = new VClock('vclock-hash');
     $namespace = new RiakNamespace('type', 'bucket');
     $location = new RiakLocation($namespace, 'riak-key');
     $domainObject->setRiakVClock($vClock);
     $domainObject->setRiakContentType('application/json');
     $domainObject->setRiakLastModified('Sat, 01 Jan 2015 01:01:01 GMT');
     $this->instance->setRiakObjectValues($riakObject, $domainObject, $location);
     $this->assertEquals('Sat, 01 Jan 2015 01:01:01 GMT', $riakObject->getLastModified());
     $this->assertEquals('application/json', $riakObject->getContentType());
     $this->assertEquals($vClock, $riakObject->getVClock());
 }