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"}'); }
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); }