Prueba de integracion para service worker
This commit is contained in:
@ -3,6 +3,7 @@ namespace Incoviba\Test\Integration;
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Faker;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Service;
|
||||
@ -20,6 +21,7 @@ class QueueTest extends TestCase
|
||||
|
||||
public function testServiceWorker(): void
|
||||
{
|
||||
$faker = Faker\Factory::create();
|
||||
$pagoData = [
|
||||
'fecha' => '2022-01-01',
|
||||
'valor' => 10000,
|
||||
@ -27,10 +29,58 @@ class QueueTest extends TestCase
|
||||
$pagoService = $this->container->get(Service\Venta\Pago::class);
|
||||
$pago = $pagoService->add($pagoData);
|
||||
|
||||
$this->assertEquals(0.0, $pago->uf);
|
||||
|
||||
$queueService = $this->container->get(Service\Queue::class);
|
||||
$queueService->run();
|
||||
|
||||
$pago = $pagoService->getById($pago->id);
|
||||
$this->assertNotEquals(0.0, $pago->uf);
|
||||
|
||||
$comunaRepository = $this->container->get(Repository\Comuna::class);
|
||||
$comunas = $comunaRepository->fetchAll();
|
||||
$id = $faker->numberBetween(0, count($comunas) - 1);
|
||||
$comuna = $comunas[$id];
|
||||
$direccionData = [
|
||||
'calle' => $faker->streetName,
|
||||
'numero' => $faker->buildingNumber,
|
||||
'comuna' => $comuna->id
|
||||
];
|
||||
$propietarioData = [
|
||||
'rut' => $faker->numberBetween(10000000, 99999999),
|
||||
'nombre' => $faker->name,
|
||||
'apellido_paterno' => $faker->lastName,
|
||||
'apellido_materno' => $faker->lastName,
|
||||
];
|
||||
$propietarioRepository = $this->container->get(Repository\Venta\Propietario::class);
|
||||
$propietario = $propietarioRepository->create($propietarioData);
|
||||
$propietario = $propietarioRepository->save($propietario);
|
||||
$propiedadRepository = $this->container->get(Repository\Venta\Propiedad::class);
|
||||
$propiedad = $propiedadRepository->create();
|
||||
$propiedad = $propiedadRepository->save($propiedad);
|
||||
$ventaData = [
|
||||
'fecha' => '2022-01-01',
|
||||
'propietario' => $propietario->rut,
|
||||
'propiedad' => $propiedad->id,
|
||||
];
|
||||
$ventaRepository = $this->container->get(Repository\Venta::class);
|
||||
$venta = $ventaRepository->create($ventaData);
|
||||
$venta = $ventaRepository->save($venta);
|
||||
|
||||
$cuotaData = [
|
||||
'venta' => $venta->id,
|
||||
'fecha' => '2022-01-01',
|
||||
'valor' => 10000,
|
||||
];
|
||||
$cuotaService = $this->container->get(Service\Venta\Cuota::class);
|
||||
$cuota = $cuotaService->add($cuotaData);
|
||||
|
||||
$this->assertEquals(0.0, $cuota->pago->uf);
|
||||
|
||||
$queueService = $this->container->get(Service\Queue::class);
|
||||
$queueService->run();
|
||||
|
||||
$cuota = $cuotaService->getById($cuota->id);
|
||||
$this->assertNotEquals(0.0, $cuota->pago->uf);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user