public function denormalize($data, $class, $format = null, array $context = []) { $category = new FavouritePlaceCategory(); $category->setId($data['id']); $category->setLabel($data['label']); return $category; }
public function testNormalization() { $category = new FavouritePlaceCategory(); $category->setLabel('Label'); $category->setId('id'); $normalized = $this->serializer->normalize($category); $this->assertCount(2, $normalized); $this->assertEquals('Label', $normalized['label']); $this->assertEquals('id', $normalized['id']); }
public function testNormalization() { $category = new FavouritePlaceCategory(); $category->setId('id'); $category->setLabel('Label'); $favouritePlace = new FavouritePlace(); $favouritePlace->setCategory($category); $favouritePlace->setLabel('City Centre'); $favouritePlace->setLocation('NG1 5AW'); $favouritePlace->setGeolocation(new Geolocation(52.9549135, -1.1582327)); $favouritePlace->setStops([new AtcoCode('3390Y4'), new AtcoCode('3390Y3'), new AtcoCode('3390Y2')]); $data = $this->extension->normalize($this->serializer, [$favouritePlace]); $this->assertInternalType('array', $data); }
public function testNormalization() { $favouritePlace = new FavouritePlace(); $favouritePlace->setLabel('City Centre'); $favouritePlace->setLocation('NG1 5AW'); $favouritePlace->setGeolocation(new Geolocation(52.9549135, -1.1582327)); $favouritePlace->setStops([new AtcoCode('3390Y4'), new AtcoCode('3390Y3'), new AtcoCode('3390Y2')]); $category = new FavouritePlaceCategory(); $category->setLabel('Label'); $category->setId('id'); $favouritePlace->setCategory($category); $normalized = $this->serializer->normalize($favouritePlace); $this->assertEquals($this->getNormalized(), $normalized); }