Get tests passing

This commit is contained in:
Brabli
2022-07-21 14:46:51 +01:00
parent 9cca12b334
commit e87294e96f
2 changed files with 8 additions and 8 deletions

View File

@@ -5,8 +5,8 @@ declare(strict_types=1);
namespace Pcm\GeocodeBundle\Service; namespace Pcm\GeocodeBundle\Service;
use Exception; use Exception;
use Pcm\GeocodeBundle\Data\LatLon;
use Pcm\GeocodeBundle\Entity\GeocodeData; use Pcm\GeocodeBundle\Entity\GeocodeData;
use Pcm\GeocodeBundle\Model\LatLonModel;
use Symfony\Contracts\HttpClient\HttpClientInterface; use Symfony\Contracts\HttpClient\HttpClientInterface;
use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Contracts\HttpClient\ResponseInterface;
@@ -17,12 +17,12 @@ class Geocoder
public function __construct(private HttpClientInterface $client) {} public function __construct(private HttpClientInterface $client) {}
/** /**
* Returns a LatLon object * Returns a LatLonModel object
* *
* @param string $postcode * @param string $postcode
* @return GeocodeData * @return GeocodeData
*/ */
public function geocodePostcode(string $postcode): LatLon public function geocodePostcode(string $postcode): LatLonModel
{ {
$client = $this->setClientHeaders(); $client = $this->setClientHeaders();
$response = $this->makeApiRequest($client, $postcode); $response = $this->makeApiRequest($client, $postcode);
@@ -59,8 +59,8 @@ class Geocoder
throw new Exception("No data was received from API response! Were the arguments valid?"); throw new Exception("No data was received from API response! Were the arguments valid?");
} }
private function createGeocodeDataObject(array $data): LatLon private function createGeocodeDataObject(array $data): LatLonModel
{ {
return new LatLon((float) $data[0]['lat'], (float) $data[0]['lon']); return new LatLonModel((float) $data[0]['lat'], (float) $data[0]['lon']);
} }
} }

View File

@@ -4,8 +4,8 @@ declare(strict_types=1);
namespace Pcm\GeocodeBundle\Tests; namespace Pcm\GeocodeBundle\Tests;
use Pcm\GeocodeBundle\Data\LatLon;
use Pcm\GeocodeBundle\Interface\MappableInterface; use Pcm\GeocodeBundle\Interface\MappableInterface;
use Pcm\GeocodeBundle\Model\LatLonModel;
use Pcm\GeocodeBundle\Service\Geocoder; use Pcm\GeocodeBundle\Service\Geocoder;
use Pcm\GeocodeBundle\Tests\AppKernel; use Pcm\GeocodeBundle\Tests\AppKernel;
use Pcm\GeocodeBundle\Trait\MappableTrait; use Pcm\GeocodeBundle\Trait\MappableTrait;
@@ -37,11 +37,11 @@ class GeocodeTest extends KernelTestCase
$this->geocoder->geocodePostcode('aaaaaaaa'); $this->geocoder->geocodePostcode('aaaaaaaa');
} }
public function testGeocodePostcodeReturnsLatLonObject(): void public function testGeocodePostcodeReturnsLatLonModel(): void
{ {
sleep(1); sleep(1);
$result = $this->geocoder->geocodePostcode(self::POSTCODE); $result = $this->geocoder->geocodePostcode(self::POSTCODE);
$this->assertInstanceOf(LatLon::class, $result); $this->assertInstanceOf(LatLonModel::class, $result);
} }
private function getMappableEntity(): MappableInterface private function getMappableEntity(): MappableInterface