86 lines
2.9 KiB
PHP
86 lines
2.9 KiB
PHP
<?php
|
|
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;
|
|
use Incoviba\Repository;
|
|
|
|
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();
|
|
}
|
|
|
|
public function testServiceWorker(): void
|
|
{
|
|
$faker = Faker\Factory::create();
|
|
$pagoData = [
|
|
'fecha' => '2022-01-01',
|
|
'valor' => 10000,
|
|
];
|
|
$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);
|
|
}
|
|
} |