/**
  * @dataProvider entityProvider
  */
 public function testEntitySerializationRoundtrips(Entity $entity)
 {
     $serializerFactory = new SerializerFactory(new DataValueSerializer());
     $deserializerFactory = new DeserializerFactory(new DataValueDeserializer(), new BasicEntityIdParser());
     $serialization = $serializerFactory->newEntitySerializer()->serialize($entity);
     $newEntity = $deserializerFactory->newEntityDeserializer()->deserialize($serialization);
     $this->assertTrue($entity->equals($newEntity));
 }
 protected function assertEntitySerialization(EntityId $id, $data)
 {
     $expectedEntity = $this->makeEntity($id);
     if (!$expectedEntity) {
         return;
     }
     $deserializer = $this->deserializerFactory->newEntityDeserializer();
     $actualEntity = $deserializer->deserialize($data);
     $this->assertTrue($expectedEntity->equals($actualEntity), 'Round trip failed for ' . $id->getSerialization());
 }
 /**
  * @return Deserializer
  */
 public function newEntityDeserializer()
 {
     $factory = new DeserializerFactory($this->newDataValueDeserializer(), new BasicEntityIdParser());
     return $factory->newEntityDeserializer();
 }
 private function newEntityDeserializer()
 {
     $wikibaseRepo = WikibaseRepo::getDefaultInstance();
     $deserializerFactory = new DeserializerFactory($wikibaseRepo->getDataValueDeserializer(), $wikibaseRepo->getEntityIdParser());
     return $deserializerFactory->newEntityDeserializer();
 }
Exemplo n.º 5
0
 public function getEntityDeserializer() : Deserializer
 {
     $factory = new DeserializerFactory($this->newDataValueDeserializer(), $this->newEntityIdParser());
     return $factory->newEntityDeserializer();
 }
 protected function setUp()
 {
     $deserializerFactory = new DeserializerFactory(new DataValueDeserializer(array('boolean' => 'DataValues\\BooleanValue', 'number' => 'DataValues\\NumberValue', 'string' => 'DataValues\\StringValue', 'unknown' => 'DataValues\\UnknownValue', 'globecoordinate' => 'DataValues\\GlobeCoordinateValue', 'monolingualtext' => 'DataValues\\MonolingualTextValue', 'multilingualtext' => 'DataValues\\MultilingualTextValue', 'quantity' => 'DataValues\\QuantityValue', 'time' => 'DataValues\\TimeValue', 'wikibase-entityid' => 'Wikibase\\DataModel\\Entity\\EntityIdValue')), new BasicEntityIdParser());
     $this->deserializer = $deserializerFactory->newEntityDeserializer();
 }