Pruebas de integracion con seeds
This commit is contained in:
40
app/tests/extension/Seeds/Proyectos.php
Normal file
40
app/tests/extension/Seeds/Proyectos.php
Normal 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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user