Files
pcm-geocode-bundle/tests/Service/GeocodeTest.php
2022-07-19 10:21:40 +01:00

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