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