Pruebas de integracion con seeds
This commit is contained in:
28
app/tests/integration/API/Ventas/MediosPago/TokuTest.php
Normal file
28
app/tests/integration/API/Ventas/MediosPago/TokuTest.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace Tests\Integration\API\Ventas\MediosPago;
|
||||
|
||||
use Tests\Extension\AbstractIntegration;
|
||||
|
||||
class TokuTest extends AbstractIntegration
|
||||
{
|
||||
public function testCuotas()
|
||||
{
|
||||
|
||||
}
|
||||
public function testSuccess()
|
||||
{
|
||||
|
||||
}
|
||||
public function testTest()
|
||||
{
|
||||
|
||||
}
|
||||
public function testReset()
|
||||
{
|
||||
|
||||
}
|
||||
public function testEnqueue()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,13 +1,17 @@
|
||||
<?php
|
||||
namespace Incoviba\Test\Integration;
|
||||
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Faker;
|
||||
use Incoviba\Common\Define;
|
||||
use Incoviba\Common\Implement;
|
||||
use Incoviba\Common\Ideal;
|
||||
use Incoviba\Service;
|
||||
use Incoviba\Repository;
|
||||
use Tests\Extension\Faker\Provider\Rut;
|
||||
|
||||
class QueueTest extends TestCase
|
||||
{
|
||||
@ -22,6 +26,7 @@ class QueueTest extends TestCase
|
||||
public function testServiceWorker(): void
|
||||
{
|
||||
$faker = Faker\Factory::create();
|
||||
$faker->addProvider(new Rut($faker));
|
||||
$pagoData = [
|
||||
'fecha' => '2022-01-01',
|
||||
'valor' => 10000,
|
||||
@ -37,31 +42,65 @@ class QueueTest extends TestCase
|
||||
$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
|
||||
];
|
||||
$direccionRepository = $this->container->get(Repository\Direccion::class);
|
||||
$direcciones = $direccionRepository->fetchAll();
|
||||
$direccion = $faker->randomElement($direcciones);
|
||||
$rut = $faker->rut(false, false);
|
||||
$propietarioData = [
|
||||
'rut' => $faker->numberBetween(10000000, 99999999),
|
||||
'nombre' => $faker->name,
|
||||
'rut' => $rut,
|
||||
'dv' => $faker->digitoVerificador($rut),
|
||||
'direccion' => $direccion->id,
|
||||
'nombres' => $faker->firstName,
|
||||
'apellido_paterno' => $faker->lastName,
|
||||
'apellido_materno' => $faker->lastName,
|
||||
'email' => $faker->email,
|
||||
'telefono' => $faker->randomNumber(9),
|
||||
];
|
||||
$propietarioRepository = $this->container->get(Repository\Venta\Propietario::class);
|
||||
$propietario = $propietarioRepository->create($propietarioData);
|
||||
$propietario = $propietarioRepository->save($propietario);
|
||||
$proyectoRepository = $this->container->get(Repository\Proyecto::class);
|
||||
$proyectos = $proyectoRepository->fetchAll();
|
||||
$proyecto = $faker->randomElement($proyectos);
|
||||
$tipoUnidadRepository = $this->container->get(Repository\Proyecto\TipoUnidad::class);
|
||||
$tiposUnidades = $tipoUnidadRepository->fetchAll();
|
||||
$tipoUnidad = $faker->randomElement($tiposUnidades);
|
||||
$proyectoTipoUnidadData = [
|
||||
'proyecto' => $proyecto->id,
|
||||
'tipo' => $tipoUnidad->id,
|
||||
'nombre' => $faker->word,
|
||||
'descripcion' => $faker->sentence,
|
||||
'abreviacion' => substr($faker->word, 0, 1),
|
||||
'logia' => $faker->randomFloat(2, 1, 20),
|
||||
'terraza' => $faker->randomFloat(2, 1, 20),
|
||||
'm2' => $faker->randomFloat(2, 20, 100),
|
||||
];
|
||||
$proyectoTipoUnidadRepository = $this->container->get(Repository\Proyecto\ProyectoTipoUnidad::class);
|
||||
$proyectoTipoUnidad = $proyectoTipoUnidadRepository->create($proyectoTipoUnidadData);
|
||||
$proyectoTipoUnidad = $proyectoTipoUnidadRepository->save($proyectoTipoUnidad);
|
||||
$unidadData = [
|
||||
'proyecto' => $proyecto->id,
|
||||
'tipo' => $tipoUnidad->id,
|
||||
'piso' => $faker->numberBetween(1, 300),
|
||||
'descripcion' => "{$tipoUnidad->descripcion} {$faker->numberBetween(1, 300)}",
|
||||
'orientacion' => $faker->randomElement(['N', 'NE', 'NO', 'S', 'SE', 'SO', 'E', 'O']),
|
||||
'pt' => $proyectoTipoUnidad->id,
|
||||
];
|
||||
$unidadRepository = $this->container->get(Repository\Venta\Unidad::class);
|
||||
$unidad = $unidadRepository->create($unidadData);
|
||||
$unidad = $unidadRepository->save($unidad);
|
||||
$propiedadData = [
|
||||
'unidad_principal' => $unidad->id,
|
||||
];
|
||||
$propiedadRepository = $this->container->get(Repository\Venta\Propiedad::class);
|
||||
$propiedad = $propiedadRepository->create();
|
||||
$propiedad = $propiedadRepository->create($propiedadData);
|
||||
$propiedad = $propiedadRepository->save($propiedad);
|
||||
$fecha = $faker->date;
|
||||
$ventaData = [
|
||||
'fecha' => '2022-01-01',
|
||||
'fecha' => $fecha,
|
||||
'propietario' => $propietario->rut,
|
||||
'propiedad' => $propiedad->id,
|
||||
'fecha_ingreso' => new DateTimeImmutable($fecha)->add(new DateInterval('P3D'))->format('Y-m-d'),
|
||||
];
|
||||
$ventaRepository = $this->container->get(Repository\Venta::class);
|
||||
$venta = $ventaRepository->create($ventaData);
|
||||
@ -83,4 +122,4 @@ class QueueTest extends TestCase
|
||||
$cuota = $cuotaService->getById($cuota->id);
|
||||
$this->assertNotEquals(0.0, $cuota->pago->uf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user