This commit is contained in:
Juan Pablo Vial
2025-08-22 09:28:53 -04:00
parent 78222eb9f1
commit 454ba41d9c
26 changed files with 1036 additions and 135 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace Tests\Extension;
use Psr\Container\ContainerInterface;
trait ContainerTrait
{
protected ContainerInterface $container;
protected function setUp(): void
{
parent::setUp();
require_once implode(DIRECTORY_SEPARATOR, [dirname(__DIR__, 2), 'setup', 'container.php']);
$this->container = buildContainer();
}
}

View File

@ -0,0 +1,117 @@
<?php
namespace Incoviba\Tests\Integration\API\Ventas;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Define;
use Incoviba\Common\Implement;
use Incoviba\Common\Ideal;
use Incoviba\Model;
use Incoviba\Service;
use Incoviba\Repository;
use Tests\Extension\AbstractIntegration;
use Tests\Extension\ContainerTrait;
use Tests\Extension\Faker\Provider\Rut;
class ReservationTest extends TestCase
{
use ContainerTrait;
public function testAdd(): void
{
$faker = Faker\Factory::create('es_CL');
$faker->addProvider(new Rut($faker));
$comunas = $this->container->get(Repository\Comuna::class)->fetchAll();
$projects = $this->container->get(Repository\Proyecto::class)->fetchAll();
$project = $faker->randomElement($projects);
$unitTypes = $this->container->get(Repository\Proyecto\TipoUnidad::class)->fetchAll();
$unitsRepository = $this->container->get(Repository\Venta\Unidad::class);
$units = [];
$unitsValue = [];
$unitsCount = $faker->numberBetween(1, 3);
for ($i = 0; $i < $unitsCount; $i++) {
$type = $faker->randomElement($unitTypes);
$units[] = $unitsRepository->fetchByProyectoAndTipo($project->id, $type->id);
$unitsValue[] = $faker->randomFloat(2, 1000, 10000);
}
$brokersCount = $faker->numberBetween(1, 3);
for ($i = 0; $i < $brokersCount; $i++) {
$rut = $faker->rut(false, false);
$brokerData = [
'rut' => $rut,
'digit' => $faker->digitoVerificador($rut),
'name' => $faker->firstName,
'legal_name' => $faker->company,
'contact' => $faker->name,
'email' => $faker->email,
'phone' => $faker->phoneNumber
];
$broker = $this->container->get(Repository\Proyecto\Broker::class)->create($brokerData);
$broker = $this->container->get(Repository\Proyecto\Broker::class)->save($broker);
$contractData = [
'project_id' => $project->id,
'broker_rut' => $broker->rut,
'commission' => $faker->randomFloat(4, 0, 1),
];
$contract = $this->container->get(Repository\Proyecto\Broker\Contract::class)->create($contractData);
$contract = $this->container->get(Repository\Proyecto\Broker\Contract::class)->save($contract);
$state = $this->container->get(Repository\Proyecto\Broker\Contract\State::class)->create([
'contract_id' => $contract->id,
'type' => Model\Proyecto\Broker\Contract\State\Type::ACTIVE->value,
'date' => $faker->dateTimeBetween('-2 months')->format('Y-m-d')
]);
$this->container->get(Repository\Proyecto\Broker\Contract\State::class)->save($state);
}
$contracts = $this->container->get(Repository\Proyecto\Broker\Contract::class)->fetchActiveByProject($project->id);
$broker = $faker->boolean(10) ? $faker->randomElement($contracts)->broker : null;
$activePromotions = $this->container->get(Repository\Venta\Promotion::class)->fetchActiveByProject($project->id);
$promotionsCount = $faker->numberBetween(0, 3);
$promotions = [];
for ($i = 0; $i < $promotionsCount; $i++) {
$promotions[] = $faker->randomElement($activePromotions)->id;
}
$rut = $faker->rut(false, false);
$data = [
'project_id' => $faker->randomElement($projects)->id,
'date' => $faker->dateTimeBetween('-2 years', 'now')->format('Y-m-d'),
'buyer_rut' => $rut,
'buyer_digit' => $faker->digitoVerificador($rut),
'buyer_names' => $faker->firstName,
'buyer_last_name' => $faker->lastName,
'buyer_last_name2' => $faker->lastName,
'buyer_email' => $faker->email,
'buyer_phone' => $faker->phoneNumber,
'buyer_address_street' => $faker->streetName,
'buyer_address_number' => $faker->buildingNumber,
'buyer_address_extra' => $faker->streetAddress,
'buyer_address_comuna_id' => $faker->randomElement($comunas)->id,
'units' => $units,
'units_value' => $unitsValue,
'broker_rut' => $broker ? $broker->rut : '',
];
if (count($promotions) > 0) {
$data['promotions'] = $promotions;
}
$reservation = $this->container->get(Service\Venta\Reservation::class)->add($data);
$this->assertInstanceOf(Model\Venta\Reservation::class, $reservation);
$this->assertEquals($data['date'], $reservation->date->format('Y-m-d'));
$this->assertEquals($data['project_id'], $reservation->project->id);
$this->assertEquals($data['buyer_rut'], $reservation->buyer->rut);
$this->assertEquals($data['buyer_digit'], $reservation->buyer->digito);
$this->assertEquals($data['buyer_names'], $reservation->buyer->nombres);
$this->assertEquals($data['buyer_last_name'], $reservation->buyer->apellido_paterno);
$this->assertEquals($data['buyer_last_name2'], $reservation->buyer->apellido_materno);
$this->assertEquals($data['buyer_email'], $reservation->buyer->datos->email);
$this->assertEquals($data['buyer_phone'], $reservation->buyer->datos->telefono);
$this->assertEquals($data['buyer_address_street'], $reservation->buyer->direccion->calle);
$this->assertEquals($data['buyer_address_number'], $reservation->buyer->direccion->numero);
$this->assertEquals($data['buyer_address_extra'], $reservation->buyer->direccion->extra);
$this->assertEquals($data['buyer_address_comuna_id'], $reservation->buyer->direccion->comuna->id);
$this->assertEquals($data['broker_rut'], $reservation->broker->rut);
}
}

View File

@ -11,17 +11,12 @@ use Incoviba\Common\Implement;
use Incoviba\Common\Ideal;
use Incoviba\Service;
use Incoviba\Repository;
use Tests\Extension\ContainerTrait;
use Tests\Extension\Faker\Provider\Rut;
class QueueTest extends TestCase
{
protected ContainerInterface $container;
protected function setUp(): void
{
require_once implode(DIRECTORY_SEPARATOR, [dirname(__DIR__, 2), 'setup', 'container.php']);
$this->container = buildContainer();
}
use ContainerTrait;
public function testServiceWorker(): void
{

View File

@ -13,7 +13,7 @@ class ReservationTest extends AbstractModel
protected function setUp(): void
{
$this->model = new Reservation();
$this->properties = ['buyer', 'date', 'units', 'promotions', 'broker'];
$this->properties = ['project', 'buyer', 'date', 'units', 'promotions', 'broker'];
$this->methods = ['states', 'currentState', 'addUnit', 'removeUnit', 'findUnit', 'hasUnit'];
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace Incoviba\Test\Repository;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Define;
use Incoviba\Model;
use Incoviba\Repository;
class DireccionTest extends TestCase
{
protected Define\Connection $connection;
protected Repository\Comuna $comunaRepository;
protected function setUp(): void
{
$this->connection = $this->getMockBuilder(Define\Connection::class)
->disableOriginalConstructor()
->getMock();
$this->comunaRepository = $this->getMockBuilder(Repository\Comuna::class)
->disableOriginalConstructor()
->getMock();
$this->comunaRepository->method('fetchById')->willReturnCallback(function ($id) {
$comuna = new Model\Comuna();
$comuna->id = $id;
return $comuna;
});
}
public function testCreate(): void
{
$direccionRepository = new Repository\Direccion($this->connection, $this->comunaRepository);
$faker = Faker\Factory::create();
$data = [
'calle' => $faker->streetName,
'numero' => $faker->randomNumber(),
'extra' => $faker->streetSuffix,
'comuna' => $faker->randomNumber(),
];
$direccion = $direccionRepository->create($data);
$this->assertTrue(!isset($direccion->id));
$this->assertEquals($data['calle'], $direccion->calle);
$this->assertEquals($data['numero'], $direccion->numero);
$this->assertEquals($data['extra'], $direccion->extra);
$this->assertEquals($data['comuna'], $direccion->comuna->id);
}
public function testSave(): void
{
$direccionRepository = new Repository\Direccion($this->connection, $this->comunaRepository);
$faker = Faker\Factory::create();
$direccion = new Model\Direccion();
$direccion->calle = $faker->streetName;
$direccion->numero = $faker->randomNumber(3);
$direccion->extra = $faker->streetSuffix;
$direccion->comuna = $this->getMockBuilder(Model\Comuna::class)->getMock();
$direccion->comuna->id = $faker->numberBetween(10000, 18000);
$direccion = $direccionRepository->save($direccion);
$this->assertTrue(isset($direccion->id));
}
}

View File

@ -0,0 +1,62 @@
<?php
namespace Incoviba\Test\Repository;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Define;
use Incoviba\Model;
use Incoviba\Repository;
class PersonaTest extends TestCase
{
protected Define\Connection $connection;
protected function setUp(): void
{
$this->connection = $this->getMockBuilder(Define\Connection::class)
->disableOriginalConstructor()
->getMock();
}
public function testCreate(): void
{
$personaRepository = new Repository\Persona($this->connection);
$faker = Faker\Factory::create();
$data = [
'rut' => $faker->randomNumber(8),
'digito' => $faker->boolean(100 - round(1 / 11 * 100)) ? $faker->randomNumber(1) : 'K',
'nombres' => $faker->name(),
'apellido_paterno' => $faker->lastName(),
'apellido_materno' => $faker->lastName()
];
$persona = $personaRepository->create($data);
$this->assertEquals($data['rut'], $persona->rut);
$this->assertEquals($data['digito'], $persona->digito);
$this->assertEquals($data['nombres'], $persona->nombres);
$this->assertEquals($data['apellido_paterno'], $persona->apellidoPaterno);
$this->assertEquals($data['apellido_materno'], $persona->apellidoMaterno);
}
public function testSave(): void
{
$personaRepository = new Repository\Persona($this->connection);
$faker = Faker\Factory::create();
$data = [
'rut' => $faker->randomNumber(8),
'digito' => $faker->boolean(100 - round(1 / 11 * 100)) ? $faker->randomNumber(1) : 'K',
'nombres' => $faker->name(),
'apellido_paterno' => $faker->lastName(),
'apellido_materno' => $faker->lastName()
];
$persona = new Model\Persona();
$persona->rut = $data['rut'];
$persona->digito = $data['digito'];
$persona->nombres = $data['nombres'];
$persona->apellidoPaterno = $data['apellido_paterno'];
$persona->apellidoMaterno = $data['apellido_materno'];
$persona = $personaRepository->save($persona);
$this->assertEquals($data['rut'], $persona->rut);
}
}

View File

@ -0,0 +1,102 @@
<?php
namespace Incoviba\Test\Repository\Venta;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Define;
use Incoviba\Model;
use Incoviba\Repository;
class ReservationTest extends TestCase
{
protected Define\Connection $connection;
protected Repository\Proyecto $proyectoRepository;
protected Repository\Persona $personaRepository;
protected Repository\Proyecto\Broker $brokerRepository;
protected Repository\Venta\Unidad $unitRepository;
protected Repository\Venta\Promotion $promotionRepository;
protected function setUp(): void
{
$this->connection = $this->getMockBuilder(Define\Connection::class)
->disableOriginalConstructor()
->getMock();
$this->proyectoRepository = $this->getMockBuilder(Repository\Proyecto::class)
->disableOriginalConstructor()
->getMock();
$this->proyectoRepository->method('fetchById')->willReturnCallback(function ($id) {
$proyecto = new Model\Proyecto();
$proyecto->id = $id;
return $proyecto;
});
$this->personaRepository = $this->getMockBuilder(Repository\Persona::class)
->disableOriginalConstructor()
->getMock();
$this->personaRepository->method('fetchById')->willReturnCallback(function ($rut) {
$persona = new Model\Persona();
$persona->rut = $rut;
return $persona;
});
$this->brokerRepository = $this->getMockBuilder(Repository\Proyecto\Broker::class)
->disableOriginalConstructor()
->getMock();
$this->brokerRepository->method('fetchById')->willReturnCallback(function ($rut) {
$broker = new Model\Proyecto\Broker();
$broker->rut = $rut;
return $broker;
});
$this->unitRepository = $this->getMockBuilder(Repository\Venta\Unidad::class)
->disableOriginalConstructor()
->getMock();
$this->unitRepository->method('fetchById')->willReturnCallback(function ($id) {
$unidad = new Model\Venta\Unidad();
$unidad->id = $id;
return $unidad;
});
$this->promotionRepository = $this->getMockBuilder(Repository\Venta\Promotion::class)
->disableOriginalConstructor()
->getMock();
$this->promotionRepository->method('fetchById')->willReturnCallback(function ($id) {
$promotion = new Model\Venta\Promotion();
$promotion->id = $id;
return $promotion;
});
}
public function testCreate(): void
{
$reservationRepository = new Repository\Venta\Reservation($this->connection, $this->proyectoRepository,
$this->personaRepository, $this->brokerRepository, $this->unitRepository, $this->promotionRepository);
$faker = Faker\Factory::create();
$data = [
'project_id' => $faker->numberBetween(1, 10),
'buyer_rut' => $faker->randomNumber(8),
'date' => $faker->dateTimeBetween('-2 years', 'now')->format('Y-m-d'),
];
$reservation = $reservationRepository->create($data);
$this->assertTrue(!isset($reservation->id));
$this->assertEquals($data['project_id'], $reservation->project->id);
$this->assertEquals($data['buyer_rut'], $reservation->buyer->rut);
$this->assertEquals($data['date'], $reservation->date->format('Y-m-d'));
}
public function testSave(): void
{
$reservationRepository = new Repository\Venta\Reservation($this->connection, $this->proyectoRepository,
$this->personaRepository, $this->brokerRepository, $this->unitRepository, $this->promotionRepository);
$faker = Faker\Factory::create();
$data = [
'project_id' => $faker->numberBetween(1, 10),
'buyer_rut' => $faker->randomNumber(8),
'date' => $faker->dateTimeBetween('-2 years', 'now')->format('Y-m-d'),
];
$reservation = new Model\Venta\Reservation();
$reservation->project = $this->proyectoRepository->fetchById($data['project_id']);
$reservation->buyer = $this->personaRepository->fetchById($data['buyer_rut']);
$reservation->date = new DateTimeImmutable($data['date']);
$reservation = $reservationRepository->save($reservation);
$this->assertTrue(isset($reservation->id));
}
}

View File

@ -0,0 +1,64 @@
<?php
namespace Incoviba\Test\Service;
use Psr\Log\LoggerInterface;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Implement;
use Incoviba\Exception\ServiceAction;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
class DireccionTest extends TestCase
{
protected LoggerInterface $logger;
protected Repository\Direccion $direccionRepository;
protected function setUp(): void
{
$this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$this->direccionRepository = $this->getMockBuilder(Repository\Direccion::class)
->disableOriginalConstructor()
->getMock();
$this->direccionRepository->method('fetchByCalleAndNumeroAndExtraAndComuna')
->willThrowException(new Implement\Exception\EmptyResult(''));
$this->direccionRepository->method('filterData')->willReturnArgument(0);
$this->direccionRepository->method('create')->willReturnCallback(function($data) {
$direccion = new Model\Direccion();
$direccion->calle = $data['calle'];
$direccion->numero = $data['numero'];
$direccion->extra = $data['extra'];
$direccion->comuna = $this->getMockBuilder(Model\Comuna::class)
->disableOriginalConstructor()->getMock();
$direccion->comuna->id = $data['comuna'];
return $direccion;
});
$this->direccionRepository->method('save')->willReturnCallback(function($direccion) {
$direccion->id = 1;
return $direccion;
});
}
public function testAdd(): void
{
$direccionService = new Service\Direccion($this->logger, $this->direccionRepository);
$faker = Faker\Factory::create('es_ES');
$data = [
'street' => $faker->streetName,
'number' => $faker->randomNumber(3),
'extra' => $faker->word,
'comuna_id' => $faker->numberBetween(10000, 18000),
];
$direccion = $direccionService->add($data);
$this->assertEquals($data['street'], $direccion->calle);
$this->assertEquals($data['number'], $direccion->numero);
$this->assertEquals($data['extra'], $direccion->extra);
$this->assertEquals($data['comuna_id'], $direccion->comuna->id);
}
}

View File

@ -0,0 +1,65 @@
<?php
namespace Incoviba\Test\Service;
use Psr\Log\LoggerInterface;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Implement;
use Incoviba\Exception\ServiceAction;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
use Incoviba\Common\Define;
use Incoviba\Common\Ideal;
class PersonaTest extends TestCase
{
protected LoggerInterface $logger;
protected Repository\Persona $personaRepository;
protected Repository\Persona\Datos $datosPersonaRepository;
protected Repository\Venta\Propietario $propietarioRepository;
protected Service\Direccion $direccionService;
protected function setUp(): void
{
$this->logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
$this->personaRepository = $this->getMockBuilder(Repository\Persona::class)
->disableOriginalConstructor()->getMock();
$this->personaRepository->method('fetchById')->willThrowException(new Implement\Exception\EmptyResult(''));
$this->personaRepository->method('filterData')->willReturnArgument(0);
$this->personaRepository->method('create')->willReturnCallback(function($data) {
$persona = new Model\Persona();
$persona->rut = $data['rut'];
$persona->digito = $data['digito'];
$persona->nombres = $data['nombres'];
$persona->apellidoPaterno = $data['apellido_paterno'];
$persona->apellidoMaterno = $data['apellido_materno'];
return $persona;
});
$this->personaRepository->method('save')->willReturnArgument(0);
$this->datosPersonaRepository = $this->getMockBuilder(Repository\Persona\Datos::class)
->disableOriginalConstructor()->getMock();
$this->propietarioRepository = $this->getMockBuilder(Repository\Venta\Propietario::class)
->disableOriginalConstructor()->getMock();
$this->propietarioRepository->method('fetchById')->willThrowException(new Implement\Exception\EmptyResult(''));
$this->direccionService = $this->getMockBuilder(Service\Direccion::class)
->disableOriginalConstructor()->getMock();
}
public function testAdd(): void
{
$personaService = new Service\Persona($this->logger, $this->personaRepository, $this->datosPersonaRepository,
$this->propietarioRepository, $this->direccionService);
$faker = Faker\Factory::create('es_ES');
$digit = $faker->boolean(100-round(1/11*100)) ? $faker->randomNumber(1) : 'K';
$data = [
'rut' => $faker->randomNumber(8),
'digito' => $digit,
'nombres' => $faker->name(),
'apellido_paterno' => $faker->lastName(),
'apellido_materno' => $faker->lastName(),
];
$persona = $personaService->add($data);
$this->assertEquals($data['rut'], $persona->rut);
}
}

View File

@ -1,5 +1,5 @@
<?php
namespace Inventario\Service\Venta;
namespace Incoviba\Test\Service\Venta;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
@ -70,4 +70,4 @@ class PagoTest extends TestCase
$this->assertTrue($status);
$this->assertEquals($pago->uf, $this->uf);
}
}
}

View File

@ -0,0 +1,118 @@
<?php
namespace Incoviba\Tests\Unit\Service\Venta;
use DateTimeImmutable;
use Psr\Log\LoggerInterface;
use PHPUnit\Framework\TestCase;
use Faker;
use Incoviba\Common\Implement;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
class ReservationTest extends TestCase
{
protected LoggerInterface $logger;
protected Repository\Venta\Reservation $reservationRepository;
protected Repository\Venta\Reservation\State $stateRepository;
protected Service\Persona $personaService;
protected Service\Proyecto\Broker $brokerService;
protected Service\Venta\Promotion $promotionService;
protected Service\Venta\Unidad $unitService;
protected function setUp(): void
{
$this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()->getMock();
$this->reservationRepository = $this->getMockBuilder(Repository\Venta\Reservation::class)
->disableOriginalConstructor()->getMock();
$this->reservationRepository->method('fetchByBuyerAndDate')->willThrowException(new Implement\Exception\EmptyResult(''));
$this->reservationRepository->method('filterData')->willReturnArgument(0);
$this->reservationRepository->method('create')->willReturnCallback(function($data) {
$reservation = new Model\Venta\Reservation();
$reservation->buyer = $this->getMockBuilder(Model\Persona::class)->disableOriginalConstructor()->getMock();
$reservation->buyer->rut = $data['buyer_rut'];
$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)) {
$reservation->broker = $this->getMockBuilder(Model\Proyecto\Broker::class)->disableOriginalConstructor()->getMock();
$reservation->broker->rut = $data['broker_rut'];
}
return $reservation;
});
$this->reservationRepository->method('save')->willReturnCallback(function($reservation) {
$reservation->id = 1;
return $reservation;
});
$this->stateRepository = $this->getMockBuilder(Repository\Venta\Reservation\State::class)
->disableOriginalConstructor()->getMock();
$this->personaService = $this->getMockBuilder(Service\Persona::class)
->disableOriginalConstructor()->getMock();
$this->personaService->method('add')->willReturnCallback(function($data) {
$persona = new Model\Persona();
$persona->rut = $data['rut'];
return $persona;
});
$this->brokerService = $this->getMockBuilder(Service\Proyecto\Broker::class)
->disableOriginalConstructor()->getMock();
$this->promotionService = $this->getMockBuilder(Service\Venta\Promotion::class)
->disableOriginalConstructor()->getMock();
$this->unitService = $this->getMockBuilder(Service\Venta\Unidad::class)
->disableOriginalConstructor()->getMock();
$this->unitService->method('getById')->willReturnCallback(function($id) {
$unit = new Model\Venta\Unidad();
$unit->id = $id;
return $unit;
});
}
public function testAdd(): void
{
$faker = Faker\Factory::create();
$reservationService = new Service\Venta\Reservation($this->logger, $this->reservationRepository,
$this->stateRepository, $this->personaService, $this->brokerService, $this->promotionService,
$this->unitService);
$units = [];
$unitsValue = [];
$unitsCount = $faker->numberBetween(1, 10);
for ($i = 0; $i < $unitsCount; $i++) {
$units[] = $faker->numberBetween(1, 100);
$unitsValue[] = $faker->randomFloat(2, 1000, 10000);
}
$digit = $faker->boolean(100-round(1/11*100)) ? $faker->randomNumber(1) : 'K';
$broker = $faker->boolean(10) ? $faker->randomNumber(8, true) : '';
$promotions = [];
$promotionsCount = $faker->numberBetween(0, 10);
for ($i = 0; $i < $promotionsCount; $i++) {
$promotions[] = $faker->numberBetween(1, 100);
}
$data = [
'project_id' => $faker->numberBetween(1, 100),
'date' => $faker->dateTimeBetween('-1 year', 'now')->format('Y-m-d'),
'buyer_rut' => $faker->randomNumber(8, true),
'buyer_digit' => $digit,
'buyer_names' => $faker->firstName(),
'buyer_last_name' => $faker->lastName(),
'buyer_last_name2' => $faker->lastName(),
'buyer_address_street' => $faker->streetName(),
'buyer_address_number' => $faker->randomNumber(3),
'buyer_address_comuna' => $faker->numberBetween(10000, 18000),
'buyer_marital_status' => $faker->word(),
'buyer_email' => $faker->email(),
'buyer_phone' => $faker->randomNumber(9),
'buyer_profession' => $faker->word(),
'buyer_birthdate' => $faker->dateTimeBetween('-80 year', '-18 year')->format('Y-m-d'),
'units' => $units,
'units_value' => $unitsValue,
'broker_rut' => $broker,
'promotions' => $promotions
];
$reservation = $reservationService->add($data);
$this->assertEquals($data['project_id'], $reservation->project->id);
$this->assertEquals($data['buyer_rut'], $reservation->buyer->rut);
$this->assertCount($unitsCount, $reservation->units);
}
}