public function testNormalizeWithoutLocation()
 {
     $expectedFeatureName = "the feature name comes from the label by default";
     $favouritePlace = new FavouritePlace();
     $favouritePlace->setGeolocation(new Geolocation(52.9549135, -1.1582327));
     $favouritePlace->setLabel($expectedFeatureName);
     $normalized = $this->serializer->normalize($favouritePlace);
     $expectedGeometry = ["type" => "Point", "coordinates" => [52.9549135, -1.1582327]];
     $this->assertEquals($expectedGeometry, $normalized['feature']['geometry']);
     $this->assertEquals($expectedFeatureName, $normalized['feature']['properties']['name']);
 }
 public function testValidation()
 {
     $favouritePlace = new FavouritePlace();
     $this->assertEquals(1, $this->validator->validate($favouritePlace, 'create')->count());
     $favouritePlace = new FavouritePlace();
     $favouritePlace->setId('fp-' . uniqid());
     $this->assertEquals(0, $this->validator->validate($favouritePlace, 'create')->count());
     $favouritePlace = new FavouritePlace();
     $favouritePlace->setId('fp-' . uniqid());
     $this->assertEquals(2, $this->validator->validate($favouritePlace, 'update')->count());
     $favouritePlace = new FavouritePlace();
     $favouritePlace->setId('fp-' . uniqid());
     $favouritePlace->setLabel(['Work']);
     $favouritePlace->setLocation('City Centre');
     $this->assertEquals(0, $this->validator->validate($favouritePlace, 'update')->count());
 }
 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);
 }