feat: upgrade phpunit to 12.5

This commit is contained in:
Björn Fromme
2026-08-31 09:31:00 +02:00
parent 010cfe56b2
commit bfad61f1dd
95 changed files with 1436 additions and 1224 deletions
+23 -11
View File
@@ -15,7 +15,7 @@ use Psr\Log\LoggerInterface;
class TravelEnricherTest extends TestCase
{
private TravelEnricher $service;
private ?TravelEnricher $service = null;
private PickupLoader $pickupLoader;
private HotelLoader $hotelLoader;
private InsuranceLoader $insuranceLoader;
@@ -23,12 +23,15 @@ class TravelEnricherTest extends TestCase
protected function setUp(): void
{
$this->pickupLoader = $this->createMock(PickupLoader::class);
$this->hotelLoader = $this->createMock(HotelLoader::class);
$this->insuranceLoader = $this->createMock(InsuranceLoader::class);
$this->logger = $this->createMock(LoggerInterface::class);
$this->pickupLoader = $this->createStub(PickupLoader::class);
$this->hotelLoader = $this->createStub(HotelLoader::class);
$this->insuranceLoader = $this->createStub(InsuranceLoader::class);
$this->logger = $this->createStub(LoggerInterface::class);
}
$this->service = new TravelEnricher(
private function service(): TravelEnricher
{
return $this->service ??= new TravelEnricher(
$this->pickupLoader,
$this->hotelLoader,
$this->insuranceLoader,
@@ -42,6 +45,9 @@ class TravelEnricherTest extends TestCase
public function testEnrichFromXmlReturnsTrueOnSuccess(): void
{
$this->pickupLoader = $this->createMock(PickupLoader::class);
$this->hotelLoader = $this->createMock(HotelLoader::class);
$travel = new Travel();
$travel->id = 100;
@@ -55,11 +61,13 @@ class TravelEnricherTest extends TestCase
->method('patchHotelDetails')
->with($travel);
$this->assertTrue($this->service->enrichFromXml($travel));
$this->assertTrue($this->service()->enrichFromXml($travel));
}
public function testEnrichFromXmlReturnsFalseAndLogsWarningOnFailure(): void
{
$this->logger = $this->createMock(LoggerInterface::class);
$travel = new Travel();
$travel->id = 100;
@@ -72,7 +80,7 @@ class TravelEnricherTest extends TestCase
->method('warning')
->with('Failed to enrich travel data', $this->arrayHasKey('travelId'));
$this->assertFalse($this->service->enrichFromXml($travel));
$this->assertFalse($this->service()->enrichFromXml($travel));
}
// -------------------------------------------------------------------------
@@ -81,6 +89,8 @@ class TravelEnricherTest extends TestCase
public function testPatchInsurancesReplacesExistingInsurances(): void
{
$this->insuranceLoader = $this->createMock(InsuranceLoader::class);
$travel = new Travel();
$travel->id = 100;
@@ -104,7 +114,7 @@ class TravelEnricherTest extends TestCase
->method('loadAll')
->willReturn([$individual, $package]);
$this->service->patchInsurances($travel);
$this->service()->patchInsurances($travel);
$this->assertSame([$individual, $package], $travel->insurances);
}
@@ -126,7 +136,7 @@ class TravelEnricherTest extends TestCase
$this->insuranceLoader->method('loadAll')->willReturn([$individual, $package]);
$this->service->patchInsurances($travel);
$this->service()->patchInsurances($travel);
$this->assertCount(1, $package->containedInsurances);
$this->assertSame($individual, $package->containedInsurances[0]);
@@ -134,6 +144,8 @@ class TravelEnricherTest extends TestCase
public function testPatchInsurancesLogsWarningOnFailureAndDoesNotThrow(): void
{
$this->logger = $this->createMock(LoggerInterface::class);
$travel = new Travel();
$travel->id = 100;
$original = [];
@@ -149,7 +161,7 @@ class TravelEnricherTest extends TestCase
->with('Failed to load insurance data', $this->arrayHasKey('travelId'));
// Must not throw; insurances stay unchanged
$this->service->patchInsurances($travel);
$this->service()->patchInsurances($travel);
$this->assertSame($original, $travel->insurances);
}