56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\tests\Service;
|
|
|
|
use Pcm\GeocodeBundle\Entity\GeocodeData;
|
|
use Pcm\GeocodeBundle\Geocoder;
|
|
use Pcm\GeocodeBundle\Interface\MappableInterface;
|
|
use Pcm\GeocodeBundle\Trait\MappableTrait;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
class GeocodeTest extends TestCase
|
|
{
|
|
// Buckingham Palace
|
|
private const POSTCODE = 'SW1A 1AA';
|
|
|
|
/**
|
|
* @var \Pcm\GeocodeBundle\Geocoder
|
|
*/
|
|
private Geocoder $geocoder;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->geocoder = new Geocoder();
|
|
}
|
|
|
|
public function testGeocodeInstance(): void
|
|
{
|
|
$this->assertInstanceOf(\Pcm\GeocodeBundle\Geocoder::class, $this->geocoder);
|
|
}
|
|
|
|
public function testGeocodePostcodeThrowsOnInvalidInput(): void
|
|
{
|
|
sleep(1);
|
|
$this->expectException(\Exception::class);
|
|
$this->geocoder->geocodePostcode('aaaaaaaa');
|
|
}
|
|
|
|
public function testGeocodePostcodeReturnsGeocodeObject(): void
|
|
{
|
|
sleep(1);
|
|
$result = $this->geocoder->geocodePostcode(self::POSTCODE);
|
|
$this->assertInstanceOf(GeocodeData::class, $result);
|
|
}
|
|
|
|
private function getMappableEntity(): MappableInterface
|
|
{
|
|
return new class implements MappableInterface
|
|
{
|
|
use MappableTrait;
|
|
};
|
|
}
|
|
|
|
}
|