chore: adjust and cleanup tests

This commit is contained in:
Björn Fromme
2025-10-18 17:15:31 +02:00
parent 479b177e90
commit 0f8fed605c
10 changed files with 52 additions and 148 deletions
+8 -4
View File
@@ -7,8 +7,10 @@ namespace App\Tests\Service;
use App\BusProNet\ApiClient;
use App\BusProNet\Model\Travel;
use App\BusProNet\XmlLoader\HotelLoader;
use App\BusProNet\XmlLoader\InsuranceLoader;
use App\BusProNet\XmlLoader\PickupLoader;
use App\BusProNet\XmlLoader\TravelLoader;
use App\Exception\TravelNotFoundException;
use App\Service\TravelDataService;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
@@ -21,6 +23,7 @@ class TravelDataServiceTest extends TestCase
private TravelLoader $travelLoader;
private HotelLoader $hotelLoader;
private PickupLoader $pickupLoader;
private InsuranceLoader $insuranceLoader;
private ApiClient $apiClient;
private CacheInterface $cache;
private LoggerInterface $logger;
@@ -30,6 +33,7 @@ class TravelDataServiceTest extends TestCase
$this->travelLoader = $this->createMock(TravelLoader::class);
$this->hotelLoader = $this->createMock(HotelLoader::class);
$this->pickupLoader = $this->createMock(PickupLoader::class);
$this->insuranceLoader = $this->createMock(InsuranceLoader::class);
$this->apiClient = $this->createMock(ApiClient::class);
$this->cache = $this->createMock(CacheInterface::class);
$this->logger = $this->createMock(LoggerInterface::class);
@@ -38,6 +42,7 @@ class TravelDataServiceTest extends TestCase
$this->travelLoader,
$this->hotelLoader,
$this->pickupLoader,
$this->insuranceLoader,
$this->apiClient,
$this->cache,
$this->logger,
@@ -84,7 +89,7 @@ class TravelDataServiceTest extends TestCase
->expects($this->once())
->method('loadById')
->with($dateId, $hotelId)
->willReturn(null);
->willThrowException(new TravelNotFoundException($dateId));
$this->pickupLoader
->expects($this->never())
@@ -94,9 +99,8 @@ class TravelDataServiceTest extends TestCase
->expects($this->never())
->method('patchHotelDetails');
$result = $this->service->getTravelDataFromXml($dateId, $hotelId);
$this->assertNull($result);
$this->expectException(TravelNotFoundException::class);
$this->service->getTravelDataFromXml($dateId, $hotelId);
}
public function testGetTravelDataFromApiSuccess(): void