Tweak how errors are thrown

This commit is contained in:
2024-09-26 10:35:22 +01:00
parent 9588938356
commit 412c4eb579
2 changed files with 14 additions and 7 deletions

View File

@@ -4,9 +4,9 @@ declare(strict_types=1);
namespace Pcm\GeocodeBundle\Tests;
use Pcm\GeocodeBundle\Exception\MissingGeocodeDataException;
use Pcm\GeocodeBundle\Interface\Entity\GeocodeInterface;
use Pcm\GeocodeBundle\Trait\Entity\GeocodeTrait;
use Pcm\GeocodeBundle\Exception\ApiErrorException;
use Pcm\GeocodeBundle\Exception\NoResultsFoundException;
use Pcm\GeocodeBundle\Model\GeoCoordinates;
use Pcm\GeocodeBundle\Service\Geocoder;
@@ -33,9 +33,9 @@ final class GeocoderTest extends KernelTestCase
public function testGeocodeThrowsOnEmptyInput(): void
{
sleep(1);
$this->expectException(ApiErrorException::class);
$this->expectException(MissingGeocodeDataException::class);
$entity = $this->createEntity('');
$this->expectExceptionMessageMatches("/Nothing to search for.$/");
$this->expectExceptionMessageMatches("/No geocode data present./");
$this->geocoder->geocode($entity);
}
@@ -43,7 +43,7 @@ final class GeocoderTest extends KernelTestCase
{
sleep(1);
$this->expectException(NoResultsFoundException::class);
$this->expectExceptionMessageMatches("/No results found.$/");
$this->expectExceptionMessageMatches("/No results found with geocode data \"Invalid Postcode\"./");
$entity = $this->createEntity('Invalid Postcode');
$this->geocoder->geocode($entity);
}