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); }
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()); }