chore: adjust and cleanup tests
This commit is contained in:
@@ -8,7 +8,9 @@ use App\BusProNet\Model\Insurance;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Service\BookingPriceCalculatorService;
|
||||
use App\Service\InsuranceEligibilityService;
|
||||
use App\Service\InsuranceMatchingService;
|
||||
use App\Service\InsuranceTypeFilterService;
|
||||
use Carbon\Carbon;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
@@ -25,7 +27,20 @@ class InsuranceMatchingServiceTest extends TestCase
|
||||
->method('calculateIndividualParticipantPriceExcludingInsurance')
|
||||
->willReturn(500.0); // Default test price
|
||||
|
||||
$this->service = new InsuranceMatchingService($this->priceCalculator);
|
||||
// Mock InsuranceTypeFilterService - just return the input array for filterByType
|
||||
$insuranceTypeFilterService = $this->createMock(InsuranceTypeFilterService::class);
|
||||
$insuranceTypeFilterService->method('filterByType')
|
||||
->willReturnArgument(0);
|
||||
|
||||
// Use real InsuranceEligibilityService since it has no dependencies
|
||||
// and these tests are actually testing the eligibility filtering logic
|
||||
$insuranceEligibilityService = new InsuranceEligibilityService();
|
||||
|
||||
$this->service = new InsuranceMatchingService(
|
||||
$this->priceCalculator,
|
||||
$insuranceTypeFilterService,
|
||||
$insuranceEligibilityService
|
||||
);
|
||||
|
||||
// Set a fixed test date for consistent test results
|
||||
Carbon::setTestNow('2024-06-01 12:00:00');
|
||||
|
||||
@@ -28,7 +28,7 @@ class ParticipantCardDataServiceTest extends TestCase
|
||||
// Create test room
|
||||
$room = new Room();
|
||||
$room->id = 1;
|
||||
$room->name = 'Doppelzimmer';
|
||||
$room->label = 'Doppelzimmer';
|
||||
$room->price = 100.0;
|
||||
|
||||
$travel = new Travel();
|
||||
@@ -98,7 +98,7 @@ class ParticipantCardDataServiceTest extends TestCase
|
||||
|
||||
$result = $this->service->getCardData($bookingDto, 0);
|
||||
|
||||
$this->assertEquals('Teilnehmer 1', $result['name']);
|
||||
$this->assertEquals('Anmelder:in', $result['name']);
|
||||
}
|
||||
|
||||
public function testGetCardDataWithEmptyName(): void
|
||||
@@ -120,7 +120,7 @@ class ParticipantCardDataServiceTest extends TestCase
|
||||
|
||||
$result = $this->service->getCardData($bookingDto, 0);
|
||||
|
||||
$this->assertEquals('Teilnehmer 1', $result['name']);
|
||||
$this->assertEquals('Anmelder:in', $result['name']);
|
||||
}
|
||||
|
||||
public function testGetCardDataWithNoRoomAssignment(): void
|
||||
@@ -205,11 +205,11 @@ class ParticipantCardDataServiceTest extends TestCase
|
||||
// Create test rooms
|
||||
$room1 = new Room();
|
||||
$room1->id = 1;
|
||||
$room1->name = 'Einzelzimmer';
|
||||
$room1->label = 'Einzelzimmer';
|
||||
|
||||
$room2 = new Room();
|
||||
$room2->id = 2;
|
||||
$room2->name = 'Doppelzimmer';
|
||||
$room2->label = 'Doppelzimmer';
|
||||
|
||||
$travel = new Travel();
|
||||
$travel->rooms = [$room1, $room2];
|
||||
@@ -255,7 +255,7 @@ class ParticipantCardDataServiceTest extends TestCase
|
||||
$this->assertEquals('500,00 €', $result[1]['price']);
|
||||
|
||||
// Third participant (no name)
|
||||
$this->assertEquals('Teilnehmer 3', $result[2]['name']);
|
||||
$this->assertEquals('Teilnehmer:in 2', $result[2]['name']);
|
||||
$this->assertEquals('Doppelzimmer', $result[2]['roomName']);
|
||||
$this->assertEquals('480,00 €', $result[2]['price']);
|
||||
}
|
||||
@@ -312,8 +312,8 @@ class ParticipantCardDataServiceTest extends TestCase
|
||||
$result2 = $this->service->getCardData($bookingDto, 1);
|
||||
$result3 = $this->service->getCardData($bookingDto, 2);
|
||||
|
||||
$this->assertEquals('Teilnehmer 1', $result1['name']);
|
||||
$this->assertEquals('Teilnehmer 2', $result2['name']);
|
||||
$this->assertEquals('Teilnehmer 3', $result3['name']);
|
||||
$this->assertEquals('Anmelder:in', $result1['name']);
|
||||
$this->assertEquals('Teilnehmer:in 1', $result2['name']);
|
||||
$this->assertEquals('Teilnehmer:in 2', $result3['name']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user