예제 #1
0
 public function testSerializeWithEmptyArray()
 {
     $country = new Country();
     $country->setName('France');
     $country->citiesAre([]);
     $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"}');
 }
예제 #2
0
 public function testDeserializeWithTypeCollectionIdentifiedObjectShouldNotProcessSubObjectWithUnknownIdentifierAttribute()
 {
     $cityPalaiseau = new City();
     $cityPalaiseau->setName('Palaiseau');
     $country = new Country();
     $country->setName('France');
     $country->citiesAre([$cityPalaiseau]);
     $configuration = new Configuration();
     $configuration->identifierAttribute('type');
     $configurationObject = new Configuration\Object(new ClassName(Country::class));
     $configurationObject->attributeUseMethod('name', 'setName', 'getName')->attributeUseCollectionIdentifiedObject('cities', 'citiesAre', 'getCities')->registerToConfigurationWithIdentifier($configuration, 'country');
     $configurationObject = new Configuration\Object(new ClassName(City::class));
     $configurationObject->attributeUseMethod('name', 'setName', 'getName')->registerToConfigurationWithIdentifier($configuration, 'city');
     $this->given($this->newTestedInstance($configuration))->object($this->testedInstance->deserialize('{"type": "country", "name": "France","cities":[ 
                 {"type": "city", "name":"Palaiseau"}, {"type": "unknownType", "name":"Paris"} 
             ]}', new ClassName(Country::class)))->isCloneOf($country);
 }