boot(); $this->geocoder = $kernel->getContainer()->get('pcm_geocode.geocoder'); } public function testGeocodeThrowsOnEmptyInput(): void { sleep(1); $this->expectException(MissingGeocodeDataException::class); $entity = $this->createEntity(''); $this->expectExceptionMessageMatches("/No geocode data present./"); $this->geocoder->geocode($entity); } public function testGeocodeThrowsOnInvalidPostcode(): void { sleep(1); $this->expectException(NoResultsFoundException::class); $this->expectExceptionMessageMatches("/No results found with geocode data \"Invalid Postcode\"./"); $entity = $this->createEntity('Invalid Postcode'); $this->geocoder->geocode($entity); } public function testGeocodeReturnsGeoCoordinates(): GeoCoordinates { sleep(1); $entity = $this->createEntity(self::POSTCODE); $geoCoords = $this->geocoder->geocode($entity); $this->assertNotNull($geoCoords); return $geoCoords; } /** * @depends testGeocodeReturnsGeoCoordinates */ public function testCoordinatesAreSet(GeoCoordinates $geoCoordinates): void { $this->assertIsFloat($geoCoordinates->latitude); $this->assertIsFloat($geoCoordinates->longitude); } private function getGeocodableEntity(): GeocodeInterface { return new class implements GeocodeInterface { use GeocodeTrait; }; } private function createEntity(string $data): GeocodeInterface { $entity = new class implements GeocodeInterface { use GeocodeTrait; public string $data; public function getGeocodeData(): string { return $this->data; } }; $entity->data = $data; return $entity; } }