Reservation fixes

This commit is contained in:
Juan Pablo Vial
2025-09-09 20:16:04 -03:00
parent 1caa0c954e
commit feb61db660
5 changed files with 47 additions and 25 deletions

View File

@ -37,7 +37,7 @@ class ReservationTest extends TestCase
$unitsValue[] = $faker->randomFloat(2, 1000, 10000);
}
$broker = $faker->optional(.1)->randomElement($brokers);
$broker = $faker->randomElement($brokers);
$activePromotions = $this->container->get(Repository\Venta\Promotion::class)->fetchActiveByProject($project->id);
@ -87,5 +87,6 @@ class ReservationTest extends TestCase
if ($broker !== null) {
$this->assertEquals($data['broker_rut'], $reservation->broker->rut);
}
$this->assertEquals(1, $reservation->currentState()->type->value);
}
}

View File

@ -35,7 +35,7 @@ class ReservationTest extends TestCase
$reservation->project = $this->getMockBuilder(Model\Proyecto::class)->disableOriginalConstructor()->getMock();
$reservation->project->id = $data['project_id'];
$reservation->date = new DateTimeImmutable($data['date']);
if (array_key_exists('broker_rut', $data)) {
if (array_key_exists('broker_rut', $data) and !empty($data['broker_rut'])) {
$reservation->broker = $this->getMockBuilder(Model\Proyecto\Broker::class)->disableOriginalConstructor()->getMock();
$reservation->broker->rut = $data['broker_rut'];
}
@ -47,6 +47,12 @@ class ReservationTest extends TestCase
});
$this->stateRepository = $this->getMockBuilder(Repository\Venta\Reservation\State::class)
->disableOriginalConstructor()->getMock();
$this->stateRepository->method('fetchByReservation')->willReturnCallback(function($reservation_id) {
$state = new Model\Venta\Reservation\State();
$state->reservation = new Model\Venta\Reservation();
$state->reservation->id = $reservation_id;
return $state;
});
$this->personaService = $this->getMockBuilder(Service\Persona::class)
->disableOriginalConstructor()->getMock();
$this->personaService->method('add')->willReturnCallback(function($data) {
@ -61,6 +67,11 @@ class ReservationTest extends TestCase
});
$this->brokerService = $this->getMockBuilder(Service\Proyecto\Broker::class)
->disableOriginalConstructor()->getMock();
$this->brokerService->method('get')->willReturnCallback(function($id) {
$broker = new Model\Proyecto\Broker();
$broker->rut = $id;
return $broker;
});
$this->promotionService = $this->getMockBuilder(Service\Venta\Promotion::class)
->disableOriginalConstructor()->getMock();
$this->promotionService->method('getById')->willReturnCallback(function($id) {