57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Pcm\GeocodeBundle\Tests;
|
|
|
|
use Pcm\GeocodeBundle\Data\LatLon;
|
|
use Pcm\GeocodeBundle\Interface\MappableInterface;
|
|
use Pcm\GeocodeBundle\Service\Geocoder;
|
|
use Pcm\GeocodeBundle\Tests\AppKernel;
|
|
use Pcm\GeocodeBundle\Trait\MappableTrait;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
|
|
class GeocodeTest extends KernelTestCase
|
|
{
|
|
// Buckingham Palace
|
|
private const POSTCODE = 'SW1A 1AA';
|
|
|
|
private Geocoder $geocoder;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$kernel = new AppKernel('test', false);
|
|
$kernel->boot();
|
|
$this->geocoder = $kernel->getContainer()->get(Geocoder::class);
|
|
|
|
}
|
|
|
|
public function testGeocodeInstance(): void
|
|
{
|
|
$this->assertInstanceOf(\Pcm\GeocodeBundle\Service\Geocoder::class, $this->geocoder);
|
|
}
|
|
|
|
public function testGeocodePostcodeThrowsOnInvalidInput(): void
|
|
{
|
|
sleep(1);
|
|
$this->expectException(\Exception::class);
|
|
$this->geocoder->geocodePostcode('aaaaaaaa');
|
|
}
|
|
|
|
public function testGeocodePostcodeReturnsLatLonObject(): void
|
|
{
|
|
sleep(1);
|
|
$result = $this->geocoder->geocodePostcode(self::POSTCODE);
|
|
$this->assertInstanceOf(LatLon::class, $result);
|
|
}
|
|
|
|
private function getMappableEntity(): MappableInterface
|
|
{
|
|
return new class implements MappableInterface
|
|
{
|
|
use MappableTrait;
|
|
};
|
|
}
|
|
|
|
}
|