Ejemplo n.º 1
0
 public function testSerializeWithEmptyCountable()
 {
     $country = new Country();
     $country->setName('France');
     $country->citiesInTraversable(new \ArrayObject());
     $configuration = new Configuration();
     $configurationObject = new Configuration\Object(new ClassName(City::class));
     $configurationObject->attributeUseMethod('name', 'setName', 'getName')->attributeUseObject('country', new ClassName(Country::class), 'countryIs', 'getCountry')->registerToConfiguration($configuration);
     $configurationObject = new Configuration\Object(new ClassName(Country::class));
     $configurationObject->attributeUseMethod('name', 'setName', 'getName')->registerToConfiguration($configuration);
     $this->given($this->newTestedInstance($configuration))->string($this->testedInstance->serialize($country))->isIdenticalTo('{"name":"France"}');
 }
Ejemplo n.º 2
0
 public function testDeserializeForIdentifiedObjectShouldThrowExceptionWhenJsonDontHaveIdentifier()
 {
     $configuration = new Configuration();
     $configuration->identifierAttribute('type');
     $configurationObject = new Configuration\Object(new ClassName(City::class));
     $configurationObject->attributeUseMethod('name', 'setName', 'getName')->registerToConfigurationWithIdentifier($configuration, 'city');
     $this->given($this->newTestedInstance($configuration))->exception(function () {
         $this->testedInstance->deserialize('{"name": "Palaiseau"}');
     })->isInstanceOf(MissingIdentifierAttribute::class);
 }