Pruebas de integracion con seeds

This commit is contained in:
Juan Pablo Vial
2025-06-24 21:55:02 -04:00
parent 360537c638
commit ca1ed3f870
26 changed files with 1133 additions and 418 deletions

View File

@ -0,0 +1,33 @@
<?php
namespace Tests\Extension\Seeds;
use Tests\Extension\AbstractSeed;
class Direcciones extends AbstractSeed
{
public function run(): void
{
$comunas = $this->loadValues('comuna', columns: 'id');
$n = 50;
$data = [];
for ($i = 0; $i < $n; $i++) {
$row = [
'calle' => $this->faker->streetName,
'numero' => $this->faker->randomNumber(5),
'comuna' => $this->faker->randomElement($comunas),
'extra' => '',
];
$extraRand = ((int) round(rand() / getrandmax())) === 1;
if ($extraRand) {
$nExtra = (int) round(rand(1, 3));
$row['extra'] = $this->faker->words($nExtra, true);
}
$data[] = $row;
}
$this->table('direccion')
->insertValues($data)
->save();
}
}

View File

@ -0,0 +1,39 @@
<?php
namespace Tests\Extension\Seeds;
use Tests\Extension\AbstractSeed;
class Inmobiliarias extends AbstractSeed
{
public function run(): void
{
$tipos = $this->loadValues('tipo_sociedad', columns: 'id');
$suffixes = [
'Inmobiliaria ',
'Administradora ',
'Asesorías ',
''
];
$n = 5;
$data = [];
for ($i = 0; $i < $n; $i++) {
$rut = $this->faker->rut(false, false);
$abreviacion = $this->faker->streetName;
$suffix = $this->faker->randomElement($suffixes);
$razon = "{$suffix}{$abreviacion}";
$sigla = strtoupper(substr($abreviacion, 0, 3));
$data []= [
'rut' => $rut,
'dv' => $this->faker->digitoVerificador($rut),
'razon' => $razon,
'abreviacion' => $abreviacion,
'sigla' => $sigla,
'sociedad' => $this->faker->randomElement($tipos),
];
}
$this->table('inmobiliaria')
->insertValues($data)
->save();
}
}

View File

@ -0,0 +1,40 @@
<?php
namespace Tests\Extension\Seeds;
use Tests\Extension\AbstractSeed;
class Proyectos extends AbstractSeed
{
public function getDependencies(): array
{
return [
Inmobiliarias::class,
Direcciones::class
];
}
public function run(): void
{
$inmobiliarias = $this->loadValues('inmobiliaria', columns: 'rut');
$direcciones = $this->loadValues('direccion', columns: 'id');
$n = 10;
$data = [];
for ($i = 0; $i < $n; $i++) {
$data[] = [
'inmobiliaria' => $this->faker->randomElement($inmobiliarias),
'descripcion' => $this->faker->words(2, true),
'direccion' => $this->faker->randomElement($direcciones),
'superficie_sobre_nivel' => $this->faker->randomFloat(2, 1000, 10000),
'superficie_bajo_nivel' => $this->faker->randomFloat(2, 0, 5000),
'pisos' => $this->faker->randomNumber(2),
'subterraneos' => $this->faker->randomNumber(2),
'corredor' => $this->faker->randomFloat(4, 0, 1)
];
}
$this->table('proyecto')
->insertValues($data)
->save();
}
}