wip: modernized edit flow, fix insurance tier calculation
This commit is contained in:
@@ -6,8 +6,7 @@ namespace App\Tests\Form\Service\Condition;
|
||||
|
||||
use App\BusProNet\Model\Booking;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingEditDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Service\Condition\InsuranceMutabilityCondition;
|
||||
use Carbon\Carbon;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -35,7 +34,7 @@ class InsuranceMutabilityConditionTest extends TestCase
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = new \DateTimeImmutable('+10 days');
|
||||
|
||||
$bookingDto = new BookingCreateDto($travel, 123);
|
||||
$bookingDto = new BookingDto($travel, 123);
|
||||
|
||||
$result = $this->condition->evaluate($bookingDto, 0, []);
|
||||
|
||||
@@ -154,7 +153,7 @@ class InsuranceMutabilityConditionTest extends TestCase
|
||||
$this->assertStringContainsString('3', $result);
|
||||
}
|
||||
|
||||
private function createEditDto(\DateTimeImmutable $travelDate, \DateTimeImmutable $bookingDate): BookingEditDto
|
||||
private function createEditDto(\DateTimeImmutable $travelDate, \DateTimeImmutable $bookingDate): BookingDto
|
||||
{
|
||||
$booking = new Booking();
|
||||
$booking->bookingDate = $bookingDate;
|
||||
@@ -162,6 +161,9 @@ class InsuranceMutabilityConditionTest extends TestCase
|
||||
$travel = new Travel();
|
||||
$travel->dateFrom = $travelDate;
|
||||
|
||||
return new BookingEditDto($booking, $travel);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->booking = $booking;
|
||||
|
||||
return $bookingDto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Insurance;
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantInsuranceFieldHandler;
|
||||
use App\Service\InsuranceMatchingService;
|
||||
@@ -229,8 +229,8 @@ class ParticipantInsuranceFieldHandlerTest extends TestCase
|
||||
return $insurance;
|
||||
}
|
||||
|
||||
private function createMockBookingDto(): BookingCreateDto
|
||||
private function createMockBookingDto(): BookingDto
|
||||
{
|
||||
return $this->createMock(BookingCreateDto::class);
|
||||
return $this->createMock(BookingDto::class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ declare(strict_types=1);
|
||||
namespace App\Tests\Form\Service;
|
||||
|
||||
use App\BusProNet\Model\Travel;
|
||||
use App\Form\Model\BookingCreateDto;
|
||||
use App\Form\Model\BookingDto;
|
||||
use App\Form\Model\ParticipantDto;
|
||||
use App\Form\Service\ParticipantLicensePlateFieldHandler;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -38,7 +38,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
public function testProcessFieldWithoutParticipant(): void
|
||||
{
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$submittedData = ['licensePlate' => 'AB-CD 123'];
|
||||
|
||||
$this->handler->processField($submittedData, $bookingDto, 0);
|
||||
@@ -54,7 +54,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->licensePlate = 'AB-CD 123'; // Should be cleared
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => 'XY-ZZ 999'];
|
||||
@@ -70,7 +70,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => 'AB-CD 123'];
|
||||
@@ -86,7 +86,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => ''];
|
||||
@@ -102,7 +102,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => null];
|
||||
@@ -118,7 +118,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => ' AB-CD 123 '];
|
||||
@@ -134,7 +134,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = ['licensePlate' => ' '];
|
||||
@@ -150,7 +150,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
// Test with integer value
|
||||
@@ -170,7 +170,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant->parking = true; // Parking selected
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant];
|
||||
|
||||
$submittedData = []; // No licensePlate field
|
||||
@@ -189,7 +189,7 @@ class ParticipantLicensePlateFieldHandlerTest extends TestCase
|
||||
$participant2->parking = true;
|
||||
|
||||
$travel = new Travel();
|
||||
$bookingDto = new BookingCreateDto($travel, 1);
|
||||
$bookingDto = new BookingDto($travel, 1);
|
||||
$bookingDto->participants = [$participant1, $participant2];
|
||||
|
||||
$submittedData = ['licensePlate' => 'AB-CD 123'];
|
||||
|
||||
Reference in New Issue
Block a user