Pruebas de integracion con seeds
This commit is contained in:
@ -16,376 +16,27 @@ class Comuna extends AbstractSeed
|
|||||||
*/
|
*/
|
||||||
public function run(): void
|
public function run(): void
|
||||||
{
|
{
|
||||||
/*id descripcion provincia
|
|
||||||
1101 Iquique 11
|
|
||||||
1107 Alto Hospicio 11
|
|
||||||
1401 Pozo Almonte 14
|
|
||||||
1402 Camiña 14
|
|
||||||
1403 Colchane 14
|
|
||||||
1404 Huara 14
|
|
||||||
1405 Pica 14
|
|
||||||
2101 Antofagasta 21
|
|
||||||
2102 Mejillones 21
|
|
||||||
2103 Sierra Gorda 21
|
|
||||||
2104 Taltal 21
|
|
||||||
2201 Calama 22
|
|
||||||
2202 Ollagüe 22
|
|
||||||
2203 San Pedro de Atacama 22
|
|
||||||
2301 Tocopilla 23
|
|
||||||
2302 María Elena 23
|
|
||||||
3101 Copiapó 31
|
|
||||||
3102 Caldera 31
|
|
||||||
3103 Tierra Amarilla 31
|
|
||||||
3201 Chañaral 32
|
|
||||||
3202 Diego de Almagro 32
|
|
||||||
3301 Vallenar 33
|
|
||||||
3302 Alto del Carmen 33
|
|
||||||
3303 Freirina 33
|
|
||||||
3304 Huasco 33
|
|
||||||
4101 La Serena 41
|
|
||||||
4102 Coquimbo 41
|
|
||||||
4103 Andacollo 41
|
|
||||||
4104 La Higuera 41
|
|
||||||
4105 Paiguano 41
|
|
||||||
4106 Vicuña 41
|
|
||||||
4201 Illapel 42
|
|
||||||
4202 Canela 42
|
|
||||||
4203 Los Vilos 42
|
|
||||||
4204 Salamanca 42
|
|
||||||
4301 Ovalle 43
|
|
||||||
4302 Combarbalá 43
|
|
||||||
4303 Monte Patria 43
|
|
||||||
4304 Punitaqui 43
|
|
||||||
4305 Río Hurtado 43
|
|
||||||
5101 Valparaíso 51
|
|
||||||
5102 Casablanca 51
|
|
||||||
5103 Concón 51
|
|
||||||
5104 Juan Fernández 51
|
|
||||||
5105 Puchuncaví 51
|
|
||||||
5107 Quintero 51
|
|
||||||
5109 Viña del Mar 51
|
|
||||||
5201 Isla de Pascua 52
|
|
||||||
5301 Los Andes 53
|
|
||||||
5302 Calle Larga 53
|
|
||||||
5303 Rinconada 53
|
|
||||||
5304 San Esteban 53
|
|
||||||
5401 La Ligua 54
|
|
||||||
5402 Cabildo 54
|
|
||||||
5403 Papudo 54
|
|
||||||
5404 Petorca 54
|
|
||||||
5405 Zapallar 54
|
|
||||||
5501 Quillota 55
|
|
||||||
5502 Calera 55
|
|
||||||
5503 Hijuelas 55
|
|
||||||
5504 La Cruz 55
|
|
||||||
5506 Nogales 55
|
|
||||||
5601 San Antonio 56
|
|
||||||
5602 Algarrobo 56
|
|
||||||
5603 Cartagena 56
|
|
||||||
5604 El Quisco 56
|
|
||||||
5605 El Tabo 56
|
|
||||||
5606 Santo Domingo 56
|
|
||||||
5701 San Felipe 57
|
|
||||||
5702 Catemu 57
|
|
||||||
5703 Llaillay 57
|
|
||||||
5704 Panquehue 57
|
|
||||||
5705 Putaendo 57
|
|
||||||
5706 Santa María 57
|
|
||||||
5801 Quilpué 58
|
|
||||||
5802 Limache 58
|
|
||||||
5803 Olmué 58
|
|
||||||
5804 Villa Alemana 58
|
|
||||||
6101 Rancagua 61
|
|
||||||
6102 Codegua 61
|
|
||||||
6103 Coinco 61
|
|
||||||
6104 Coltauco 61
|
|
||||||
6105 Doñihue 61
|
|
||||||
6106 Graneros 61
|
|
||||||
6107 Las Cabras 61
|
|
||||||
6108 Machalí 61
|
|
||||||
6109 Malloa 61
|
|
||||||
6110 Mostazal 61
|
|
||||||
6111 Olivar 61
|
|
||||||
6112 Peumo 61
|
|
||||||
6113 Pichidegua 61
|
|
||||||
6114 Quinta de Tilcoco 61
|
|
||||||
6115 Rengo 61
|
|
||||||
6116 Requínoa 61
|
|
||||||
6117 San Vicente 61
|
|
||||||
6201 Pichilemu 62
|
|
||||||
6202 La Estrella 62
|
|
||||||
6203 Litueche 62
|
|
||||||
6204 Marchihue 62
|
|
||||||
6205 Navidad 62
|
|
||||||
6206 Paredones 62
|
|
||||||
6301 San Fernando 63
|
|
||||||
6302 Chépica 63
|
|
||||||
6303 Chimbarongo 63
|
|
||||||
6304 Lolol 63
|
|
||||||
6305 Nancagua 63
|
|
||||||
6306 Palmilla 63
|
|
||||||
6307 Peralillo 63
|
|
||||||
6308 Placilla 63
|
|
||||||
6309 Pumanque 63
|
|
||||||
6310 Santa Cruz 63
|
|
||||||
7101 Talca 71
|
|
||||||
7102 Constitución 71
|
|
||||||
7103 Curepto 71
|
|
||||||
7104 Empedrado 71
|
|
||||||
7105 Maule 71
|
|
||||||
7106 Pelarco 71
|
|
||||||
7107 Pencahue 71
|
|
||||||
7108 Río Claro 71
|
|
||||||
7109 San Clemente 71
|
|
||||||
7110 San Rafael 71
|
|
||||||
7201 Cauquenes 72
|
|
||||||
7202 Chanco 72
|
|
||||||
7203 Pelluhue 72
|
|
||||||
7301 Curicó 73
|
|
||||||
7302 Hualañé 73
|
|
||||||
7303 Licantén 73
|
|
||||||
7304 Molina 73
|
|
||||||
7305 Rauco 73
|
|
||||||
7306 Romeral 73
|
|
||||||
7307 Sagrada Familia 73
|
|
||||||
7308 Teno 73
|
|
||||||
7309 Vichuquén 73
|
|
||||||
7401 Linares 74
|
|
||||||
7402 Colbún 74
|
|
||||||
7403 Longaví 74
|
|
||||||
7404 Parral 74
|
|
||||||
7405 Retiro 74
|
|
||||||
7406 San Javier 74
|
|
||||||
7407 Villa Alegre 74
|
|
||||||
7408 Yerbas Buenas 74
|
|
||||||
8101 Concepción 81
|
|
||||||
8102 Coronel 81
|
|
||||||
8103 Chiguayante 81
|
|
||||||
8104 Florida 81
|
|
||||||
8105 Hualqui 81
|
|
||||||
8106 Lota 81
|
|
||||||
8107 Penco 81
|
|
||||||
8108 San Pedro de la Paz 81
|
|
||||||
8109 Santa Juana 81
|
|
||||||
8110 Talcahuano 81
|
|
||||||
8111 Tomé 81
|
|
||||||
8112 Hualpén 81
|
|
||||||
8201 Lebu 82
|
|
||||||
8202 Arauco 82
|
|
||||||
8203 Cañete 82
|
|
||||||
8204 Contulmo 82
|
|
||||||
8205 Curanilahue 82
|
|
||||||
8206 Los Álamos 82
|
|
||||||
8207 Tirúa 82
|
|
||||||
8301 Los Ángeles 83
|
|
||||||
8302 Antuco 83
|
|
||||||
8303 Cabrero 83
|
|
||||||
8304 Laja 83
|
|
||||||
8305 Mulchén 83
|
|
||||||
8306 Nacimiento 83
|
|
||||||
8307 Negrete 83
|
|
||||||
8308 Quilaco 83
|
|
||||||
8309 Quilleco 83
|
|
||||||
8310 San Rosendo 83
|
|
||||||
8311 Santa Bárbara 83
|
|
||||||
8312 Tucapel 83
|
|
||||||
8313 Yumbel 83
|
|
||||||
8314 Alto Biobío 83
|
|
||||||
8401 Chillán 84
|
|
||||||
8402 Bulnes 84
|
|
||||||
8403 Cobquecura 84
|
|
||||||
8404 Coelemu 84
|
|
||||||
8405 Coihueco 84
|
|
||||||
8406 Chillán Viejo 84
|
|
||||||
8407 El Carmen 84
|
|
||||||
8408 Ninhue 84
|
|
||||||
8409 Ñiquén 84
|
|
||||||
8410 Pemuco 84
|
|
||||||
8411 Pinto 84
|
|
||||||
8412 Portezuelo 84
|
|
||||||
8413 Quillón 84
|
|
||||||
8414 Quirihue 84
|
|
||||||
8415 Ránquil 84
|
|
||||||
8416 San Carlos 84
|
|
||||||
8417 San Fabián 84
|
|
||||||
8418 San Ignacio 84
|
|
||||||
8419 San Nicolás 84
|
|
||||||
8420 Treguaco 84
|
|
||||||
8421 Yungay 84
|
|
||||||
9101 Temuco 91
|
|
||||||
9102 Carahue 91
|
|
||||||
9103 Cunco 91
|
|
||||||
9104 Curarrehue 91
|
|
||||||
9105 Freire 91
|
|
||||||
9106 Galvarino 91
|
|
||||||
9107 Gorbea 91
|
|
||||||
9108 Lautaro 91
|
|
||||||
9109 Loncoche 91
|
|
||||||
9110 Melipeuco 91
|
|
||||||
9111 Nueva Imperial 91
|
|
||||||
9112 Padre las Casas 91
|
|
||||||
9113 Perquenco 91
|
|
||||||
9114 Pitrufquén 91
|
|
||||||
9115 Pucón 91
|
|
||||||
9116 Saavedra 91
|
|
||||||
9117 Teodoro Schmidt 91
|
|
||||||
9118 Toltén 91
|
|
||||||
9119 Vilcún 91
|
|
||||||
9120 Villarrica 91
|
|
||||||
9121 Cholchol 91
|
|
||||||
9201 Angol 92
|
|
||||||
9202 Collipulli 92
|
|
||||||
9203 Curacautín 92
|
|
||||||
9204 Ercilla 92
|
|
||||||
9205 Lonquimay 92
|
|
||||||
9206 Los Sauces 92
|
|
||||||
9207 Lumaco 92
|
|
||||||
9208 Purén 92
|
|
||||||
9209 Renaico 92
|
|
||||||
9210 Traiguén 92
|
|
||||||
9211 Victoria 92
|
|
||||||
10101 Puerto Montt 101
|
|
||||||
10102 Calbuco 101
|
|
||||||
10103 Cochamó 101
|
|
||||||
10104 Fresia 101
|
|
||||||
10105 Frutillar 101
|
|
||||||
10106 Los Muermos 101
|
|
||||||
10107 Llanquihue 101
|
|
||||||
10108 Maullín 101
|
|
||||||
10109 Puerto Varas 101
|
|
||||||
10201 Castro 102
|
|
||||||
10202 Ancud 102
|
|
||||||
10203 Chonchi 102
|
|
||||||
10204 Curaco de Vélez 102
|
|
||||||
10205 Dalcahue 102
|
|
||||||
10206 Puqueldón 102
|
|
||||||
10207 Queilén 102
|
|
||||||
10208 Quellón 102
|
|
||||||
10209 Quemchi 102
|
|
||||||
10210 Quinchao 102
|
|
||||||
10301 Osorno 103
|
|
||||||
10302 Puerto Octay 103
|
|
||||||
10303 Purranque 103
|
|
||||||
10304 Puyehue 103
|
|
||||||
10305 Río Negro 103
|
|
||||||
10306 San Juan de la Costa 103
|
|
||||||
10307 San Pablo 103
|
|
||||||
10401 Chaitén 104
|
|
||||||
10402 Futaleufú 104
|
|
||||||
10403 Hualaihué 104
|
|
||||||
10404 Palena 104
|
|
||||||
11101 Coihaique 111
|
|
||||||
11102 Lago Verde 111
|
|
||||||
11201 Aisén 112
|
|
||||||
11202 Cisnes 112
|
|
||||||
11203 Guaitecas 112
|
|
||||||
11301 Cochrane 113
|
|
||||||
11302 O’Higgins 113
|
|
||||||
11303 Tortel 113
|
|
||||||
11401 Chile Chico 114
|
|
||||||
11402 Río Ibáñez 114
|
|
||||||
12101 Punta Arenas 121
|
|
||||||
12102 Laguna Blanca 121
|
|
||||||
12103 Río Verde 121
|
|
||||||
12104 San Gregorio 121
|
|
||||||
12201 Cabo de Hornos (Ex Navarino) 122
|
|
||||||
12202 Antártica 122
|
|
||||||
12301 Porvenir 123
|
|
||||||
12302 Primavera 123
|
|
||||||
12303 Timaukel 123
|
|
||||||
12401 Natales 124
|
|
||||||
12402 Torres del Paine 124
|
|
||||||
13101 Santiago 131
|
|
||||||
13102 Cerrillos 131
|
|
||||||
13103 Cerro Navia 131
|
|
||||||
13104 Conchalí 131
|
|
||||||
13105 El Bosque 131
|
|
||||||
13106 Estación Central 131
|
|
||||||
13107 Huechuraba 131
|
|
||||||
13108 Independencia 131
|
|
||||||
13109 La Cisterna 131
|
|
||||||
13110 La Florida 131
|
|
||||||
13111 La Granja 131
|
|
||||||
13112 La Pintana 131
|
|
||||||
13113 La Reina 131
|
|
||||||
13114 Las Condes 131
|
|
||||||
13115 Lo Barnechea 131
|
|
||||||
13116 Lo Espejo 131
|
|
||||||
13117 Lo Prado 131
|
|
||||||
13118 Macul 131
|
|
||||||
13119 Maipú 131
|
|
||||||
13120 Ñuñoa 131
|
|
||||||
13121 Pedro Aguirre Cerda 131
|
|
||||||
13122 Peñalolén 131
|
|
||||||
13123 Providencia 131
|
|
||||||
13124 Pudahuel 131
|
|
||||||
13125 Quilicura 131
|
|
||||||
13126 Quinta Normal 131
|
|
||||||
13127 Recoleta 131
|
|
||||||
13128 Renca 131
|
|
||||||
13129 San Joaquín 131
|
|
||||||
13130 San Miguel 131
|
|
||||||
13131 San Ramón 131
|
|
||||||
13132 Vitacura 131
|
|
||||||
13201 Puente Alto 132
|
|
||||||
13202 Pirque 132
|
|
||||||
13203 San José de Maipo 132
|
|
||||||
13301 Colina 133
|
|
||||||
13302 Lampa 133
|
|
||||||
13303 Tiltil 133
|
|
||||||
13401 San Bernardo 134
|
|
||||||
13402 Buin 134
|
|
||||||
13403 Calera de Tango 134
|
|
||||||
13404 Paine 134
|
|
||||||
13501 Melipilla 135
|
|
||||||
13502 Alhué 135
|
|
||||||
13503 Curacaví 135
|
|
||||||
13504 María Pinto 135
|
|
||||||
13505 San Pedro 135
|
|
||||||
13601 Talagante 136
|
|
||||||
13602 El Monte 136
|
|
||||||
13603 Isla de Maipo 136
|
|
||||||
13604 Padre Hurtado 136
|
|
||||||
13605 Peñaflor 136
|
|
||||||
14101 Valdivia 141
|
|
||||||
14102 Corral 141
|
|
||||||
14103 Lanco 141
|
|
||||||
14104 Los Lagos 141
|
|
||||||
14105 Máfil 141
|
|
||||||
14106 Mariquina 141
|
|
||||||
14107 Paillaco 141
|
|
||||||
14108 Panguipulli 141
|
|
||||||
14201 La Unión 142
|
|
||||||
14202 Futrono 142
|
|
||||||
14203 Lago Ranco 142
|
|
||||||
14204 Río Bueno 142
|
|
||||||
15101 Arica 151
|
|
||||||
15102 Camarones 151
|
|
||||||
15201 Putre 152
|
|
||||||
15202 General Lagos 152
|
|
||||||
*/
|
|
||||||
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||||
|
|
||||||
$table = $this->table('comuna');
|
$table = $this->table('comuna');
|
||||||
$table->truncate();
|
$table->truncate();
|
||||||
|
|
||||||
$data = [
|
$filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'comuna.csv']);
|
||||||
['id' => 1101, 'descripcion' => 'Iquique', 'provincia' => 11],
|
$dataRows = explode(PHP_EOL, trim(file_get_contents($filename)));
|
||||||
['id' => 1107, 'descripcion' => 'Alto Hospicio', 'provincia' => 11],
|
$data = array_map(fn($row) => explode(';', $row), $dataRows);
|
||||||
['id' => 1401, 'descripcion' => 'Pozo Almonte', 'provincia' => 14],
|
$columns = array_shift($data);
|
||||||
['id' => 1402, 'descripcion' => 'Camiña', 'provincia' => 14],
|
$columns = array_map(function($column) {
|
||||||
['id' => 1403, 'descripcion' => 'Colchane', 'provincia' => 14],
|
if (str_contains($column, 'id')) {
|
||||||
['id' => 1404, 'descripcion' => 'Huara', 'provincia' => 14],
|
return 'id';
|
||||||
['id' => 1405, 'descripcion' => 'Pica', 'provincia' => 14],
|
}
|
||||||
['id' => 2101, 'descripcion' => 'Antofagasta', 'provincia' => 21],
|
return $column;
|
||||||
['id' => 2102, 'descripcion' => 'Mejillones', 'provincia' => 21],
|
}, $columns);
|
||||||
['id' => 2103, 'descripcion' => 'Sierra Gorda', 'provincia' => 21],
|
$data = array_map(function ($row) use ($columns) {
|
||||||
['id' => 2104, 'descripcion' => 'Taltal', 'provincia' => 21],
|
return array_combine($columns, $row);
|
||||||
['id' => 2201, 'descripcion' => 'Calama', 'provincia' => 22],
|
}, $data);
|
||||||
['id' => 2202, 'descripcion' => 'Ollagüe', 'provincia' => 22],
|
|
||||||
['id' => 2203, 'descripcion' => 'San Pedro de Alcántara', 'provincia' => 22],
|
$table->insert($data)->save();
|
||||||
['id' => 2301, 'descripcion' => 'Tocopilla', 'provincia' => 23],
|
|
||||||
['id' => 2302, 'descripcion' => 'María Elena', 'provincia' => 23],
|
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
42
app/resources/database/seeds/Provincia.php
Normal file
42
app/resources/database/seeds/Provincia.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Seed\AbstractSeed;
|
||||||
|
|
||||||
|
class Provincia extends AbstractSeed
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run Method.
|
||||||
|
*
|
||||||
|
* Write your database seeder using this method.
|
||||||
|
*
|
||||||
|
* More information on writing seeders is available here:
|
||||||
|
* https://book.cakephp.org/phinx/0/en/seeding.html
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||||
|
|
||||||
|
$table = $this->table('provincia');
|
||||||
|
$table->truncate();
|
||||||
|
|
||||||
|
$filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'provincia.csv']);
|
||||||
|
$dataRows = explode(PHP_EOL, trim(file_get_contents($filename)));
|
||||||
|
$data = array_map(fn($row) => explode(';', $row), $dataRows);
|
||||||
|
$columns = array_shift($data);
|
||||||
|
$columns = array_map(function($column) {
|
||||||
|
if (str_contains($column, 'id')) {
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
return $column;
|
||||||
|
}, $columns);
|
||||||
|
$data = array_map(function ($row) use ($columns) {
|
||||||
|
return array_combine($columns, $row);
|
||||||
|
}, $data);
|
||||||
|
|
||||||
|
$table->insert($data)->save();
|
||||||
|
|
||||||
|
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||||
|
}
|
||||||
|
}
|
42
app/resources/database/seeds/Region.php
Normal file
42
app/resources/database/seeds/Region.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Seed\AbstractSeed;
|
||||||
|
|
||||||
|
class Region extends AbstractSeed
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run Method.
|
||||||
|
*
|
||||||
|
* Write your database seeder using this method.
|
||||||
|
*
|
||||||
|
* More information on writing seeders is available here:
|
||||||
|
* https://book.cakephp.org/phinx/0/en/seeding.html
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||||
|
|
||||||
|
$table = $this->table('region');
|
||||||
|
$table->truncate();
|
||||||
|
|
||||||
|
$filename = implode(DIRECTORY_SEPARATOR, [getcwd(), 'resources', 'database', 'seeds', 'region.csv']);
|
||||||
|
$dataRows = explode(PHP_EOL, trim(file_get_contents($filename)));
|
||||||
|
$data = array_map(fn($row) => explode(';', $row), $dataRows);
|
||||||
|
$columns = array_shift($data);
|
||||||
|
$columns = array_map(function($column) {
|
||||||
|
if (str_contains($column, 'id')) {
|
||||||
|
return 'id';
|
||||||
|
}
|
||||||
|
return $column;
|
||||||
|
}, $columns);
|
||||||
|
$data = array_map(function ($row) use ($columns) {
|
||||||
|
return array_combine($columns, $row);
|
||||||
|
}, $data);
|
||||||
|
|
||||||
|
$table->insert($data)->save();
|
||||||
|
|
||||||
|
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||||
|
}
|
||||||
|
}
|
43
app/resources/database/seeds/TipoSociedad.php
Normal file
43
app/resources/database/seeds/TipoSociedad.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Seed\AbstractSeed;
|
||||||
|
|
||||||
|
class TipoSociedad extends AbstractSeed
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run Method.
|
||||||
|
*
|
||||||
|
* Write your database seeder using this method.
|
||||||
|
*
|
||||||
|
* More information on writing seeders is available here:
|
||||||
|
* https://book.cakephp.org/phinx/0/en/seeding.html
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||||
|
|
||||||
|
$table = $this->table('tipo_sociedad');
|
||||||
|
$table->truncate();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
'descripcion' => 'Limitada',
|
||||||
|
'abreviacion' => 'Ltda',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'Sociedad Anónima',
|
||||||
|
'abreviacion' => 'SA',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'Sociedad por Acciones',
|
||||||
|
'abreviacion' => 'SpA',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$table->insert($data)->saveData();
|
||||||
|
|
||||||
|
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||||
|
}
|
||||||
|
}
|
43
app/resources/database/seeds/TipoUnidad.php
Normal file
43
app/resources/database/seeds/TipoUnidad.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
use Phinx\Seed\AbstractSeed;
|
||||||
|
|
||||||
|
class TipoUnidad extends AbstractSeed
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run Method.
|
||||||
|
*
|
||||||
|
* Write your database seeder using this method.
|
||||||
|
*
|
||||||
|
* More information on writing seeders is available here:
|
||||||
|
* https://book.cakephp.org/phinx/0/en/seeding.html
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$this->execute('SET unique_checks=0; SET foreign_key_checks=0;');
|
||||||
|
|
||||||
|
$table = $this->table('tipo_unidad');
|
||||||
|
$table->truncate();
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
[
|
||||||
|
'descripcion' => 'departamento',
|
||||||
|
'orden' => 0,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'estacionamiento',
|
||||||
|
'orden' => 1,
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'descripcion' => 'bodega',
|
||||||
|
'orden' => 2,
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$table->insert($data)->saveData();
|
||||||
|
|
||||||
|
$this->execute('SET unique_checks=1; SET foreign_key_checks=1;');
|
||||||
|
}
|
||||||
|
}
|
347
app/resources/database/seeds/comuna.csv
Normal file
347
app/resources/database/seeds/comuna.csv
Normal file
@ -0,0 +1,347 @@
|
|||||||
|
id;descripcion;provincia
|
||||||
|
1101;Iquique;11
|
||||||
|
1107;Alto Hospicio;11
|
||||||
|
1401;Pozo Almonte;14
|
||||||
|
1402;Camiña;14
|
||||||
|
1403;Colchane;14
|
||||||
|
1404;Huara;14
|
||||||
|
1405;Pica;14
|
||||||
|
2101;Antofagasta;21
|
||||||
|
2102;Mejillones;21
|
||||||
|
2103;Sierra Gorda;21
|
||||||
|
2104;Taltal;21
|
||||||
|
2201;Calama;22
|
||||||
|
2202;Ollagüe;22
|
||||||
|
2203;San Pedro de Atacama;22
|
||||||
|
2301;Tocopilla;23
|
||||||
|
2302;María Elena;23
|
||||||
|
3101;Copiapó;31
|
||||||
|
3102;Caldera;31
|
||||||
|
3103;Tierra Amarilla;31
|
||||||
|
3201;Chañaral;32
|
||||||
|
3202;Diego de Almagro;32
|
||||||
|
3301;Vallenar;33
|
||||||
|
3302;Alto del Carmen;33
|
||||||
|
3303;Freirina;33
|
||||||
|
3304;Huasco;33
|
||||||
|
4101;La Serena;41
|
||||||
|
4102;Coquimbo;41
|
||||||
|
4103;Andacollo;41
|
||||||
|
4104;La Higuera;41
|
||||||
|
4105;Paiguano;41
|
||||||
|
4106;Vicuña;41
|
||||||
|
4201;Illapel;42
|
||||||
|
4202;Canela;42
|
||||||
|
4203;Los Vilos;42
|
||||||
|
4204;Salamanca;42
|
||||||
|
4301;Ovalle;43
|
||||||
|
4302;Combarbalá;43
|
||||||
|
4303;Monte Patria;43
|
||||||
|
4304;Punitaqui;43
|
||||||
|
4305;Río Hurtado;43
|
||||||
|
5101;Valparaíso;51
|
||||||
|
5102;Casablanca;51
|
||||||
|
5103;Concón;51
|
||||||
|
5104;Juan Fernández;51
|
||||||
|
5105;Puchuncaví;51
|
||||||
|
5107;Quintero;51
|
||||||
|
5109;Viña del Mar;51
|
||||||
|
5201;Isla de Pascua;52
|
||||||
|
5301;Los Andes;53
|
||||||
|
5302;Calle Larga;53
|
||||||
|
5303;Rinconada;53
|
||||||
|
5304;San Esteban;53
|
||||||
|
5401;La Ligua;54
|
||||||
|
5402;Cabildo;54
|
||||||
|
5403;Papudo;54
|
||||||
|
5404;Petorca;54
|
||||||
|
5405;Zapallar;54
|
||||||
|
5501;Quillota;55
|
||||||
|
5502;Calera;55
|
||||||
|
5503;Hijuelas;55
|
||||||
|
5504;La Cruz;55
|
||||||
|
5506;Nogales;55
|
||||||
|
5601;San Antonio;56
|
||||||
|
5602;Algarrobo;56
|
||||||
|
5603;Cartagena;56
|
||||||
|
5604;El Quisco;56
|
||||||
|
5605;El Tabo;56
|
||||||
|
5606;Santo Domingo;56
|
||||||
|
5701;San Felipe;57
|
||||||
|
5702;Catemu;57
|
||||||
|
5703;Llaillay;57
|
||||||
|
5704;Panquehue;57
|
||||||
|
5705;Putaendo;57
|
||||||
|
5706;Santa María;57
|
||||||
|
5801;Quilpué;58
|
||||||
|
5802;Limache;58
|
||||||
|
5803;Olmué;58
|
||||||
|
5804;Villa Alemana;58
|
||||||
|
6101;Rancagua;61
|
||||||
|
6102;Codegua;61
|
||||||
|
6103;Coinco;61
|
||||||
|
6104;Coltauco;61
|
||||||
|
6105;Doñihue;61
|
||||||
|
6106;Graneros;61
|
||||||
|
6107;Las Cabras;61
|
||||||
|
6108;Machalí;61
|
||||||
|
6109;Malloa;61
|
||||||
|
6110;Mostazal;61
|
||||||
|
6111;Olivar;61
|
||||||
|
6112;Peumo;61
|
||||||
|
6113;Pichidegua;61
|
||||||
|
6114;Quinta de Tilcoco;61
|
||||||
|
6115;Rengo;61
|
||||||
|
6116;Requínoa;61
|
||||||
|
6117;San Vicente;61
|
||||||
|
6201;Pichilemu;62
|
||||||
|
6202;La Estrella;62
|
||||||
|
6203;Litueche;62
|
||||||
|
6204;Marchihue;62
|
||||||
|
6205;Navidad;62
|
||||||
|
6206;Paredones;62
|
||||||
|
6301;San Fernando;63
|
||||||
|
6302;Chépica;63
|
||||||
|
6303;Chimbarongo;63
|
||||||
|
6304;Lolol;63
|
||||||
|
6305;Nancagua;63
|
||||||
|
6306;Palmilla;63
|
||||||
|
6307;Peralillo;63
|
||||||
|
6308;Placilla;63
|
||||||
|
6309;Pumanque;63
|
||||||
|
6310;Santa Cruz;63
|
||||||
|
7101;Talca;71
|
||||||
|
7102;Constitución;71
|
||||||
|
7103;Curepto;71
|
||||||
|
7104;Empedrado;71
|
||||||
|
7105;Maule;71
|
||||||
|
7106;Pelarco;71
|
||||||
|
7107;Pencahue;71
|
||||||
|
7108;Río Claro;71
|
||||||
|
7109;San Clemente;71
|
||||||
|
7110;San Rafael;71
|
||||||
|
7201;Cauquenes;72
|
||||||
|
7202;Chanco;72
|
||||||
|
7203;Pelluhue;72
|
||||||
|
7301;Curicó;73
|
||||||
|
7302;Hualañé;73
|
||||||
|
7303;Licantén;73
|
||||||
|
7304;Molina;73
|
||||||
|
7305;Rauco;73
|
||||||
|
7306;Romeral;73
|
||||||
|
7307;Sagrada Familia;73
|
||||||
|
7308;Teno;73
|
||||||
|
7309;Vichuquén;73
|
||||||
|
7401;Linares;74
|
||||||
|
7402;Colbún;74
|
||||||
|
7403;Longaví;74
|
||||||
|
7404;Parral;74
|
||||||
|
7405;Retiro;74
|
||||||
|
7406;San Javier;74
|
||||||
|
7407;Villa Alegre;74
|
||||||
|
7408;Yerbas Buenas;74
|
||||||
|
8101;Concepción;81
|
||||||
|
8102;Coronel;81
|
||||||
|
8103;Chiguayante;81
|
||||||
|
8104;Florida;81
|
||||||
|
8105;Hualqui;81
|
||||||
|
8106;Lota;81
|
||||||
|
8107;Penco;81
|
||||||
|
8108;San Pedro de la Paz;81
|
||||||
|
8109;Santa Juana;81
|
||||||
|
8110;Talcahuano;81
|
||||||
|
8111;Tomé;81
|
||||||
|
8112;Hualpén;81
|
||||||
|
8201;Lebu;82
|
||||||
|
8202;Arauco;82
|
||||||
|
8203;Cañete;82
|
||||||
|
8204;Contulmo;82
|
||||||
|
8205;Curanilahue;82
|
||||||
|
8206;Los Álamos;82
|
||||||
|
8207;Tirúa;82
|
||||||
|
8301;Los Ángeles;83
|
||||||
|
8302;Antuco;83
|
||||||
|
8303;Cabrero;83
|
||||||
|
8304;Laja;83
|
||||||
|
8305;Mulchén;83
|
||||||
|
8306;Nacimiento;83
|
||||||
|
8307;Negrete;83
|
||||||
|
8308;Quilaco;83
|
||||||
|
8309;Quilleco;83
|
||||||
|
8310;San Rosendo;83
|
||||||
|
8311;Santa Bárbara;83
|
||||||
|
8312;Tucapel;83
|
||||||
|
8313;Yumbel;83
|
||||||
|
8314;Alto Biobío;83
|
||||||
|
8401;Chillán;84
|
||||||
|
8402;Bulnes;84
|
||||||
|
8403;Cobquecura;84
|
||||||
|
8404;Coelemu;84
|
||||||
|
8405;Coihueco;84
|
||||||
|
8406;Chillán Viejo;84
|
||||||
|
8407;El Carmen;84
|
||||||
|
8408;Ninhue;84
|
||||||
|
8409;Ñiquén;84
|
||||||
|
8410;Pemuco;84
|
||||||
|
8411;Pinto;84
|
||||||
|
8412;Portezuelo;84
|
||||||
|
8413;Quillón;84
|
||||||
|
8414;Quirihue;84
|
||||||
|
8415;Ránquil;84
|
||||||
|
8416;San Carlos;84
|
||||||
|
8417;San Fabián;84
|
||||||
|
8418;San Ignacio;84
|
||||||
|
8419;San Nicolás;84
|
||||||
|
8420;Treguaco;84
|
||||||
|
8421;Yungay;84
|
||||||
|
9101;Temuco;91
|
||||||
|
9102;Carahue;91
|
||||||
|
9103;Cunco;91
|
||||||
|
9104;Curarrehue;91
|
||||||
|
9105;Freire;91
|
||||||
|
9106;Galvarino;91
|
||||||
|
9107;Gorbea;91
|
||||||
|
9108;Lautaro;91
|
||||||
|
9109;Loncoche;91
|
||||||
|
9110;Melipeuco;91
|
||||||
|
9111;Nueva Imperial;91
|
||||||
|
9112;Padre las Casas;91
|
||||||
|
9113;Perquenco;91
|
||||||
|
9114;Pitrufquén;91
|
||||||
|
9115;Pucón;91
|
||||||
|
9116;Saavedra;91
|
||||||
|
9117;Teodoro Schmidt;91
|
||||||
|
9118;Toltén;91
|
||||||
|
9119;Vilcún;91
|
||||||
|
9120;Villarrica;91
|
||||||
|
9121;Cholchol;91
|
||||||
|
9201;Angol;92
|
||||||
|
9202;Collipulli;92
|
||||||
|
9203;Curacautín;92
|
||||||
|
9204;Ercilla;92
|
||||||
|
9205;Lonquimay;92
|
||||||
|
9206;Los Sauces;92
|
||||||
|
9207;Lumaco;92
|
||||||
|
9208;Purén;92
|
||||||
|
9209;Renaico;92
|
||||||
|
9210;Traiguén;92
|
||||||
|
9211;Victoria;92
|
||||||
|
10101;Puerto Montt;101
|
||||||
|
10102;Calbuco;101
|
||||||
|
10103;Cochamó;101
|
||||||
|
10104;Fresia;101
|
||||||
|
10105;Frutillar;101
|
||||||
|
10106;Los Muermos;101
|
||||||
|
10107;Llanquihue;101
|
||||||
|
10108;Maullín;101
|
||||||
|
10109;Puerto Varas;101
|
||||||
|
10201;Castro;102
|
||||||
|
10202;Ancud;102
|
||||||
|
10203;Chonchi;102
|
||||||
|
10204;Curaco de Vélez;102
|
||||||
|
10205;Dalcahue;102
|
||||||
|
10206;Puqueldón;102
|
||||||
|
10207;Queilén;102
|
||||||
|
10208;Quellón;102
|
||||||
|
10209;Quemchi;102
|
||||||
|
10210;Quinchao;102
|
||||||
|
10301;Osorno;103
|
||||||
|
10302;Puerto Octay;103
|
||||||
|
10303;Purranque;103
|
||||||
|
10304;Puyehue;103
|
||||||
|
10305;Río Negro;103
|
||||||
|
10306;San Juan de la Costa;103
|
||||||
|
10307;San Pablo;103
|
||||||
|
10401;Chaitén;104
|
||||||
|
10402;Futaleufú;104
|
||||||
|
10403;Hualaihué;104
|
||||||
|
10404;Palena;104
|
||||||
|
11101;Coihaique;111
|
||||||
|
11102;Lago Verde;111
|
||||||
|
11201;Aisén;112
|
||||||
|
11202;Cisnes;112
|
||||||
|
11203;Guaitecas;112
|
||||||
|
11301;Cochrane;113
|
||||||
|
11302;O’Higgins;113
|
||||||
|
11303;Tortel;113
|
||||||
|
11401;Chile Chico;114
|
||||||
|
11402;Río Ibáñez;114
|
||||||
|
12101;Punta Arenas;121
|
||||||
|
12102;Laguna Blanca;121
|
||||||
|
12103;Río Verde;121
|
||||||
|
12104;San Gregorio;121
|
||||||
|
12201;Cabo de Hornos (Ex Navarino);122
|
||||||
|
12202;Antártica;122
|
||||||
|
12301;Porvenir;123
|
||||||
|
12302;Primavera;123
|
||||||
|
12303;Timaukel;123
|
||||||
|
12401;Natales;124
|
||||||
|
12402;Torres del Paine;124
|
||||||
|
13101;Santiago;131
|
||||||
|
13102;Cerrillos;131
|
||||||
|
13103;Cerro Navia;131
|
||||||
|
13104;Conchalí;131
|
||||||
|
13105;El Bosque;131
|
||||||
|
13106;Estación Central;131
|
||||||
|
13107;Huechuraba;131
|
||||||
|
13108;Independencia;131
|
||||||
|
13109;La Cisterna;131
|
||||||
|
13110;La Florida;131
|
||||||
|
13111;La Granja;131
|
||||||
|
13112;La Pintana;131
|
||||||
|
13113;La Reina;131
|
||||||
|
13114;Las Condes;131
|
||||||
|
13115;Lo Barnechea;131
|
||||||
|
13116;Lo Espejo;131
|
||||||
|
13117;Lo Prado;131
|
||||||
|
13118;Macul;131
|
||||||
|
13119;Maipú;131
|
||||||
|
13120;Ñuñoa;131
|
||||||
|
13121;Pedro Aguirre Cerda;131
|
||||||
|
13122;Peñalolén;131
|
||||||
|
13123;Providencia;131
|
||||||
|
13124;Pudahuel;131
|
||||||
|
13125;Quilicura;131
|
||||||
|
13126;Quinta Normal;131
|
||||||
|
13127;Recoleta;131
|
||||||
|
13128;Renca;131
|
||||||
|
13129;San Joaquín;131
|
||||||
|
13130;San Miguel;131
|
||||||
|
13131;San Ramón;131
|
||||||
|
13132;Vitacura;131
|
||||||
|
13201;Puente Alto;132
|
||||||
|
13202;Pirque;132
|
||||||
|
13203;San José de Maipo;132
|
||||||
|
13301;Colina;133
|
||||||
|
13302;Lampa;133
|
||||||
|
13303;Tiltil;133
|
||||||
|
13401;San Bernardo;134
|
||||||
|
13402;Buin;134
|
||||||
|
13403;Calera de Tango;134
|
||||||
|
13404;Paine;134
|
||||||
|
13501;Melipilla;135
|
||||||
|
13502;Alhué;135
|
||||||
|
13503;Curacaví;135
|
||||||
|
13504;María Pinto;135
|
||||||
|
13505;San Pedro;135
|
||||||
|
13601;Talagante;136
|
||||||
|
13602;El Monte;136
|
||||||
|
13603;Isla de Maipo;136
|
||||||
|
13604;Padre Hurtado;136
|
||||||
|
13605;Peñaflor;136
|
||||||
|
14101;Valdivia;141
|
||||||
|
14102;Corral;141
|
||||||
|
14103;Lanco;141
|
||||||
|
14104;Los Lagos;141
|
||||||
|
14105;Máfil;141
|
||||||
|
14106;Mariquina;141
|
||||||
|
14107;Paillaco;141
|
||||||
|
14108;Panguipulli;141
|
||||||
|
14201;La Unión;142
|
||||||
|
14202;Futrono;142
|
||||||
|
14203;Lago Ranco;142
|
||||||
|
14204;Río Bueno;142
|
||||||
|
15101;Arica;151
|
||||||
|
15102;Camarones;151
|
||||||
|
15201;Putre;152
|
||||||
|
15202;General Lagos;152
|
|
55
app/resources/database/seeds/provincia.csv
Normal file
55
app/resources/database/seeds/provincia.csv
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
id;descripcion;region
|
||||||
|
11;Iquique;1
|
||||||
|
14;Tamarugal;1
|
||||||
|
21;Antofagasta;2
|
||||||
|
22;El Loa;2
|
||||||
|
23;Tocopilla;2
|
||||||
|
31;Copiap;3
|
||||||
|
32;Chañaral;3
|
||||||
|
33;Huasco;3
|
||||||
|
41;Elqui;4
|
||||||
|
42;Choapa;4
|
||||||
|
43;Limari;4
|
||||||
|
51;Valparaíso;5
|
||||||
|
52;Isla de Pascua;5
|
||||||
|
53;Los Andes;5
|
||||||
|
54;Petorca;5
|
||||||
|
55;Quillota;5
|
||||||
|
56;San Antonio;5
|
||||||
|
57;San Felipe;5
|
||||||
|
58;Marga Marga;5
|
||||||
|
61;Cachapoal;6
|
||||||
|
62;Cardenal Caro;6
|
||||||
|
63;Colchagua;6
|
||||||
|
71;Talca;7
|
||||||
|
72;Cauquenes;7
|
||||||
|
73;Curico;7
|
||||||
|
74;Linares;7
|
||||||
|
81;Concepci;8
|
||||||
|
82;Arauco;8
|
||||||
|
83;Bío- Bío;8
|
||||||
|
84;Ñuble;8
|
||||||
|
91;Cautín;9
|
||||||
|
92;Malleco;9
|
||||||
|
101;Llanquihue;10
|
||||||
|
102;Chiloe;10
|
||||||
|
103;Osorno;10
|
||||||
|
104;Palena;10
|
||||||
|
111;Coihaique;11
|
||||||
|
112;Aisén;11
|
||||||
|
113;Capitan Prat;11
|
||||||
|
114;General Carrera;11
|
||||||
|
121;Magallanes;12
|
||||||
|
122;Antártica Chilena;12
|
||||||
|
123;Tierra del Fuego;12
|
||||||
|
124;Ultima Esperanza;12
|
||||||
|
131;Santiago;13
|
||||||
|
132;Cordillera;13
|
||||||
|
133;Chacabuco;13
|
||||||
|
134;Maipo;13
|
||||||
|
135;Melipilla;13
|
||||||
|
136;Talagante;13
|
||||||
|
141;Valdivia;14
|
||||||
|
142;Ranco;14
|
||||||
|
151;Arica;15
|
||||||
|
152;Parinacota;15
|
|
16
app/resources/database/seeds/region.csv
Normal file
16
app/resources/database/seeds/region.csv
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
id;descripcion;numeral;numeracion
|
||||||
|
1;Región de Tarapacá;I;1
|
||||||
|
2;Región de Antofagasta;II;2
|
||||||
|
3;Región de Atacama;III;3
|
||||||
|
4;Región de Coquimbo;IV;4
|
||||||
|
5;Región de Valparaíso;V;5
|
||||||
|
6;Región del Libertador Gral. Bernardo O’Higgins;VI;6
|
||||||
|
7;Región del Maule;VII;7
|
||||||
|
8;Región del Biobío;VIII;8
|
||||||
|
9;Región de la Araucanía;IX;9
|
||||||
|
10;Región de Los Lagos;X;10
|
||||||
|
11;Región Aisén del Gral. Carlos Ibáñez del Campo;XI;11
|
||||||
|
12;Región de Magallanes y de la Antártica Chilena;XII;12
|
||||||
|
13;Región Metropolitana de Santiago;RM;13
|
||||||
|
14;Región de Los Ríos;XIV;14
|
||||||
|
15;Región de Arica y Parinacota;XV;15
|
|
@ -7,11 +7,11 @@ use Incoviba\Model\Inmobiliaria\TipoSociedad;
|
|||||||
class Inmobiliaria extends Model
|
class Inmobiliaria extends Model
|
||||||
{
|
{
|
||||||
public int $rut;
|
public int $rut;
|
||||||
public ?string $dv;
|
public ?string $dv = null;
|
||||||
public ?string $razon;
|
public ?string $razon = null;
|
||||||
public ?string $abreviacion;
|
public ?string $abreviacion = null;
|
||||||
public ?TipoSociedad $tipoSociedad;
|
public ?TipoSociedad $tipoSociedad = null;
|
||||||
public string $sigla;
|
public ?string $sigla = null;
|
||||||
|
|
||||||
public function rut(): string
|
public function rut(): string
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ class Inmobiliaria extends Model
|
|||||||
'razon' => $this->razon ?? '',
|
'razon' => $this->razon ?? '',
|
||||||
'abreviacion' => $this->abreviacion ?? '',
|
'abreviacion' => $this->abreviacion ?? '',
|
||||||
'tipo_sociedad' => $this->tipoSociedad ?? '',
|
'tipo_sociedad' => $this->tipoSociedad ?? '',
|
||||||
'sigla' => $this->sigla,
|
'sigla' => $this->sigla ?? '',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,12 @@ use Incoviba\Model\Direccion;
|
|||||||
|
|
||||||
class Datos
|
class Datos
|
||||||
{
|
{
|
||||||
public ?string $sexo;
|
public ?string $sexo = null;
|
||||||
public ?string $estado_civil;
|
public ?string $estado_civil = null;
|
||||||
public ?string $profesion;
|
public ?string $profesion = null;
|
||||||
public ?Direccion $direccion;
|
public ?Direccion $direccion = null;
|
||||||
public ?int $telefono;
|
public ?int $telefono = null;
|
||||||
public ?string $email;
|
public ?string $email = null;
|
||||||
|
|
||||||
public function jsonSerialize(): mixed
|
public function jsonSerialize(): mixed
|
||||||
{
|
{
|
||||||
|
@ -9,7 +9,7 @@ class Propiedad extends Ideal\Model
|
|||||||
public array $unidades = [];
|
public array $unidades = [];
|
||||||
public bool $estado;
|
public bool $estado;
|
||||||
|
|
||||||
public function principal(): Unidad
|
public function principal(): ?Unidad
|
||||||
{
|
{
|
||||||
if (count($this->departamentos()) > 0) {
|
if (count($this->departamentos()) > 0) {
|
||||||
return $this->departamentos()[0];
|
return $this->departamentos()[0];
|
||||||
|
@ -11,8 +11,8 @@ class Propietario extends Model
|
|||||||
public string $nombres;
|
public string $nombres;
|
||||||
public array $apellidos;
|
public array $apellidos;
|
||||||
public Datos $datos;
|
public Datos $datos;
|
||||||
public ?Propietario $representante;
|
public ?Propietario $representante = null;
|
||||||
public ?bool $otro;
|
public ?bool $otro = null;
|
||||||
|
|
||||||
public function rut(): string
|
public function rut(): string
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ class Inmobiliaria extends Ideal\Repository
|
|||||||
|
|
||||||
public function create(?array $data = null): Model\Inmobiliaria
|
public function create(?array $data = null): Model\Inmobiliaria
|
||||||
{
|
{
|
||||||
$map = (new Implement\Repository\MapperParser(['dv', 'razon', 'abreviacion', 'sigla']))
|
$map = (new Implement\Repository\MapperParser(['rut', 'dv', 'razon', 'abreviacion', 'sigla']))
|
||||||
->register('sociedad', (new Implement\Repository\Mapper())
|
->register('sociedad', (new Implement\Repository\Mapper())
|
||||||
->setProperty('tipoSociedad')
|
->setProperty('tipoSociedad')
|
||||||
->setFunction(function($data) {
|
->setFunction(function($data) {
|
||||||
@ -32,9 +32,9 @@ class Inmobiliaria extends Ideal\Repository
|
|||||||
}
|
}
|
||||||
public function save(Define\Model $model): Model\Inmobiliaria
|
public function save(Define\Model $model): Model\Inmobiliaria
|
||||||
{
|
{
|
||||||
$model->rut = $this->saveNew(
|
$this->saveNew(
|
||||||
['dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'],
|
['rut', 'dv', 'razon', 'abreviacion', 'cuenta', 'banco', 'sociedad'],
|
||||||
[$model->dv, $model->razon, $model->abreviacion, $model->cuenta, $model->banco->id, $model->tipoSociedad->id]
|
[$model->rut, $model?->dv, $model?->razon, $model?->abreviacion, $model?->cuenta, $model?->banco->id, $model?->tipoSociedad->id]
|
||||||
);
|
);
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,8 @@ use Incoviba\Repository;
|
|||||||
|
|
||||||
class ProyectoTipoUnidad extends Ideal\Repository
|
class ProyectoTipoUnidad extends Ideal\Repository
|
||||||
{
|
{
|
||||||
public function __construct(Define\Connection $connection, protected Repository\Proyecto $proyectoRepository, protected Repository\Proyecto\TipoUnidad $tipoUnidadRepository)
|
public function __construct(Define\Connection $connection, protected Repository\Proyecto $proyectoRepository,
|
||||||
|
protected Repository\Proyecto\TipoUnidad $tipoUnidadRepository)
|
||||||
{
|
{
|
||||||
parent::__construct($connection);
|
parent::__construct($connection);
|
||||||
$this->setTable('proyecto_tipo_unidad');
|
$this->setTable('proyecto_tipo_unidad');
|
||||||
|
@ -23,6 +23,7 @@ class Unidad extends Ideal\Repository
|
|||||||
->register('pt', (new Implement\Repository\Mapper())
|
->register('pt', (new Implement\Repository\Mapper())
|
||||||
->setProperty('proyectoTipoUnidad')
|
->setProperty('proyectoTipoUnidad')
|
||||||
->setFunction(function($data) {
|
->setFunction(function($data) {
|
||||||
|
var_dump($data['pt']);
|
||||||
return $this->proyectoTipoUnidadService->getById($data['pt']);
|
return $this->proyectoTipoUnidadService->getById($data['pt']);
|
||||||
}));
|
}));
|
||||||
return $this->parseData(new Model\Venta\Unidad(), $data, $map);
|
return $this->parseData(new Model\Venta\Unidad(), $data, $map);
|
||||||
@ -30,8 +31,9 @@ class Unidad extends Ideal\Repository
|
|||||||
public function save(Define\Model $model): Model\Venta\Unidad
|
public function save(Define\Model $model): Model\Venta\Unidad
|
||||||
{
|
{
|
||||||
$model->id = $this->saveNew(
|
$model->id = $this->saveNew(
|
||||||
['subtipo', 'piso', 'descripcion', 'orientacion', 'pt'],
|
['proyecto', 'tipo', 'subtipo', 'piso', 'descripcion', 'abreviacion', 'orientacion', 'pt'],
|
||||||
[$model->subtipo, $model->piso, $model->descripcion, $model->orientacion, $model->proyectoTipoUnidad->id]
|
[$model->proyectoTipoUnidad->proyecto->id, $model->proyectoTipoUnidad->tipoUnidad->id, $model->subtipo,
|
||||||
|
$model->piso, $model->descripcion, $model->proyectoTipoUnidad->abreviacion, $model->orientacion, $model->proyectoTipoUnidad->id]
|
||||||
);
|
);
|
||||||
return $model;
|
return $model;
|
||||||
}
|
}
|
||||||
|
@ -52,17 +52,15 @@ class TestBootstrap
|
|||||||
{
|
{
|
||||||
public function __construct(protected array $configuration) {}
|
public function __construct(protected array $configuration) {}
|
||||||
|
|
||||||
public function run(bool $resetDatabase = false): void
|
public function run(bool $debug = false): void
|
||||||
{
|
{
|
||||||
if ($resetDatabase) {
|
|
||||||
if (Benchmark::execute([$this, 'isMigrated'])) {
|
|
||||||
Benchmark::execute([$this, 'resetDatabase']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!Benchmark::execute([$this, 'isMigrated'])) {
|
if (!Benchmark::execute([$this, 'isMigrated'])) {
|
||||||
Benchmark::execute([$this, 'migrate']);
|
Benchmark::execute([$this, 'migrate']);
|
||||||
}
|
}
|
||||||
Benchmark::execute([$this, 'seedTables']);
|
$output = Benchmark::execute([$this, 'seedTables']);
|
||||||
|
if ($debug) {
|
||||||
|
var_dump($output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected string $baseCommand = "bin/phinx";
|
protected string $baseCommand = "bin/phinx";
|
||||||
@ -74,10 +72,10 @@ class TestBootstrap
|
|||||||
|
|
||||||
return $status['missing_count'] === 0 and $status['pending_count'] === 0;
|
return $status['missing_count'] === 0 and $status['pending_count'] === 0;
|
||||||
}
|
}
|
||||||
public function migrate(): void
|
public function migrate(): false|null|string
|
||||||
{
|
{
|
||||||
$cmd = "{$this->baseCommand} migrate -e testing";
|
$cmd = "{$this->baseCommand} migrate -e testing";
|
||||||
shell_exec($cmd);
|
return shell_exec($cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resetDatabase(): void
|
public function resetDatabase(): void
|
||||||
@ -122,10 +120,15 @@ class TestBootstrap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function seedTables(): void
|
public function seedTables(): false|null|string
|
||||||
{
|
{
|
||||||
$cmd = "{$this->baseCommand} seed:run -e testing";
|
$cmd = "{$this->baseCommand} seed:run -e testing";
|
||||||
shell_exec($cmd);
|
$output = shell_exec($cmd);
|
||||||
|
|
||||||
|
$testSeeder = new Tests\Extension\TestSeeder($this->connect());
|
||||||
|
$testSeeder->run();
|
||||||
|
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PDO $connection;
|
protected PDO $connection;
|
||||||
@ -161,18 +164,24 @@ spl_autoload_register(function($className) {
|
|||||||
];
|
];
|
||||||
foreach ($namespaceMap as $namespace => $path) {
|
foreach ($namespaceMap as $namespace => $path) {
|
||||||
if (str_starts_with($className, $namespace)) {
|
if (str_starts_with($className, $namespace)) {
|
||||||
require str_replace($namespace, "{$path}/", $className) . ".php";
|
require str_replace([$namespace, '\\'], ["{$path}/", DIRECTORY_SEPARATOR], $className) . ".php";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$bootstrap = new TestBootstrap($_ENV);
|
$bootstrap = new TestBootstrap($_ENV);
|
||||||
$resetDatabase = $_ENV['RESET_DATABASE'] ?? false;
|
$resetDatabase = ($_ENV['RESET_DATABASE'] === 'true') ?? false;
|
||||||
Benchmark::execute([$bootstrap, 'run'], ['resetDatabase' => $resetDatabase]);
|
$debug = ($_ENV['DEBUG'] === 'true') ?? false;
|
||||||
|
|
||||||
|
Benchmark::execute([$bootstrap, 'run'], ['debug' => $debug]);
|
||||||
Benchmark::print();
|
Benchmark::print();
|
||||||
|
|
||||||
register_shutdown_function(function() use ($bootstrap) {
|
register_shutdown_function(function() use ($bootstrap, $resetDatabase) {
|
||||||
Benchmark::execute([$bootstrap, 'resetDatabase']);
|
$method = 'truncateTables';
|
||||||
|
if ($resetDatabase) {
|
||||||
|
$method = 'resetDatabase';
|
||||||
|
}
|
||||||
|
Benchmark::execute([$bootstrap, $method]);
|
||||||
Benchmark::print();
|
Benchmark::print();
|
||||||
});
|
});
|
||||||
|
147
app/tests/extension/AbstractSeed.php
Normal file
147
app/tests/extension/AbstractSeed.php
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Extension;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use PDOException;
|
||||||
|
use Faker;
|
||||||
|
use Tests\Extension\Faker\Provider\Rut;
|
||||||
|
|
||||||
|
abstract class AbstractSeed implements SeedInterface
|
||||||
|
{
|
||||||
|
public function __construct(PDO $connection)
|
||||||
|
{
|
||||||
|
$this->setConnection($connection);
|
||||||
|
$this->faker = Faker\Factory::create('es_AR');
|
||||||
|
$this->faker->addProvider(new Rut($this->faker));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected PDO $connection;
|
||||||
|
protected Faker\Generator $faker;
|
||||||
|
public function setConnection(PDO $connection): SeedInterface
|
||||||
|
{
|
||||||
|
$this->connection = $connection;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
public function getConnection(): PDO
|
||||||
|
{
|
||||||
|
return $this->connection;
|
||||||
|
}
|
||||||
|
public function getDependencies(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
protected string $table;
|
||||||
|
protected function table(string $table): self
|
||||||
|
{
|
||||||
|
$this->table = $table;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected array $queryQueue = [];
|
||||||
|
protected function insertValues(array $valueRows): self
|
||||||
|
{
|
||||||
|
$columns = array_keys($valueRows[0]);
|
||||||
|
$columnsString = implode(', ', array_map(fn($column) => "`{$column}`", $columns));
|
||||||
|
$placeholderArray = array_map(fn($column) => ":{$column}", $columns);
|
||||||
|
$placeholders = implode(', ', $placeholderArray);
|
||||||
|
$query = "INSERT INTO `{$this->table}` ({$columnsString}) VALUES ({$placeholders})";
|
||||||
|
$this->queryQueue []= ['query' => $query, 'values' => $valueRows];
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
protected function save(): self
|
||||||
|
{
|
||||||
|
foreach ($this->queryQueue as $entry) {
|
||||||
|
$query = $entry['query'];
|
||||||
|
$valueRows = $entry['values'];
|
||||||
|
|
||||||
|
foreach ($valueRows as $valueRow) {
|
||||||
|
try {
|
||||||
|
$this->connection->beginTransaction();
|
||||||
|
$statement = $this->connection->prepare($query);
|
||||||
|
if ($statement === false) {
|
||||||
|
$this->connection->rollBack();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$statement->execute($valueRow);
|
||||||
|
$this->connection->commit();
|
||||||
|
} catch (PDOException | \Throwable $exception) {
|
||||||
|
$this->connection->rollBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function loadValues(string $table, array $conditions = [], string|array $columns = '*'): array
|
||||||
|
{
|
||||||
|
$columns = $this->processColumns($columns);
|
||||||
|
$query = "SELECT {$columns} FROM `{$table}`";
|
||||||
|
if (count($conditions) > 0) {
|
||||||
|
$conditionsString = $this->processConditions($conditions);
|
||||||
|
$query = "{$query} WHERE {$conditionsString}";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
$statement = $this->connection->prepare($query);
|
||||||
|
$statement->execute();
|
||||||
|
} catch (PDOException) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if ($columns !== '*' and !str_contains($columns, ',')) {
|
||||||
|
return $statement->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
}
|
||||||
|
return $statement->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
} catch (PDOException) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected function processColumns(string|array $columns): string
|
||||||
|
{
|
||||||
|
if (is_array($columns)) {
|
||||||
|
$columns = implode(',', array_map(fn($column) => "`{$column}`", $columns));
|
||||||
|
}
|
||||||
|
if ($columns === '*') {
|
||||||
|
return $columns;
|
||||||
|
}
|
||||||
|
$columns = array_map(fn($column) => trim($column), explode(',', $columns));
|
||||||
|
return implode(', ', array_map(function($column) {
|
||||||
|
if (!str_contains($column, '`')) {
|
||||||
|
return "`{$column}`";
|
||||||
|
}
|
||||||
|
return $column;
|
||||||
|
}, $columns));
|
||||||
|
}
|
||||||
|
protected function processConditions(array $conditions): array
|
||||||
|
{
|
||||||
|
$processedConditions = [];
|
||||||
|
$processedValues = [];
|
||||||
|
foreach ($conditions as $condition) {
|
||||||
|
if (is_string($condition) and (str_starts_with(strtolower($condition), 'and') or str_starts_with(strtolower($condition), 'or'))) {
|
||||||
|
$processedConditions[] = $condition;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$column = $condition['column'];
|
||||||
|
$value = $condition['value'];
|
||||||
|
$match = $condition['match'] ?? 'AND';
|
||||||
|
$operator = $condition['operator'] ?? '=';
|
||||||
|
$columnValue = ":{$column}";
|
||||||
|
if (is_array($value)) {
|
||||||
|
$columnString = [];
|
||||||
|
foreach ($value as $idx => $val) {
|
||||||
|
$columnValue = ":{$column}_{$idx}";
|
||||||
|
$columnString[] = $columnValue;
|
||||||
|
$processedValues["{$column}_{$idx}"] = $val;
|
||||||
|
}
|
||||||
|
$columnValue = '(' . implode(', ', $columnString) . ')';
|
||||||
|
if (!str_contains($operator, 'IN')) {
|
||||||
|
$operator = 'IN';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$processedValues[$column] = $value;
|
||||||
|
}
|
||||||
|
$processedConditions[] = "{$match} `{$column}` {$operator} {$columnValue}";
|
||||||
|
}
|
||||||
|
return ['query' => implode(' ', $processedConditions), 'values' => $processedValues];
|
||||||
|
}
|
||||||
|
}
|
38
app/tests/extension/Faker/Provider/Rut.php
Normal file
38
app/tests/extension/Faker/Provider/Rut.php
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Extension\Faker\Provider;
|
||||||
|
|
||||||
|
use Faker\Provider\Base;
|
||||||
|
|
||||||
|
class Rut extends Base
|
||||||
|
{
|
||||||
|
public function rut(bool $withDigito = true, bool $withDotsAndSlash = true): string
|
||||||
|
{
|
||||||
|
$base = self::numberBetween(1000000, 99999999);
|
||||||
|
$rut = $base;
|
||||||
|
if ($withDotsAndSlash) {
|
||||||
|
$rut = number_format($rut, 0, ',', '.');
|
||||||
|
}
|
||||||
|
if ($withDigito) {
|
||||||
|
$digito = $this->getDigito($base);
|
||||||
|
if ($withDotsAndSlash) {
|
||||||
|
return "{$digito}-{$rut}";
|
||||||
|
}
|
||||||
|
return "{$digito}{$rut}";
|
||||||
|
}
|
||||||
|
return $rut;
|
||||||
|
}
|
||||||
|
public function digitoVerificador(string $rut): bool|string
|
||||||
|
{
|
||||||
|
if ( !preg_match("/^[0-9.]+/",$rut)) return false;
|
||||||
|
$rut = str_replace('.','',$rut);
|
||||||
|
return $this->getDigito($rut);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getDigito(string $rut): string
|
||||||
|
{
|
||||||
|
$M=0;$S=1;
|
||||||
|
for(;$rut;$rut=floor($rut/10))
|
||||||
|
$S=($S+$rut%10*(9-$M++%6))%11;
|
||||||
|
return $S?$S-1:'K';
|
||||||
|
}
|
||||||
|
}
|
27
app/tests/extension/SeedInterface.php
Normal file
27
app/tests/extension/SeedInterface.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Extension;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
|
||||||
|
interface SeedInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param PDO $connection
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setConnection(PDO $connection): self;
|
||||||
|
/**
|
||||||
|
* @return PDO
|
||||||
|
*/
|
||||||
|
public function getConnection(): PDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getDependencies(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run(): void;
|
||||||
|
}
|
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();
|
||||||
|
}
|
||||||
|
}
|
39
app/tests/extension/Seeds/Inmobiliarias.php
Normal file
39
app/tests/extension/Seeds/Inmobiliarias.php
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
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();
|
||||||
|
}
|
||||||
|
}
|
70
app/tests/extension/TestSeeder.php
Normal file
70
app/tests/extension/TestSeeder.php
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Extension;
|
||||||
|
|
||||||
|
use FilesystemIterator;
|
||||||
|
use PDO;
|
||||||
|
use PDOException;
|
||||||
|
|
||||||
|
class TestSeeder
|
||||||
|
{
|
||||||
|
public function __construct(protected PDO $connection) {}
|
||||||
|
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$seedClasses = $this->getSeedClasses();
|
||||||
|
$orderedSeeds = $this->orderedSeeds($seedClasses);
|
||||||
|
foreach ($orderedSeeds as $seed) {
|
||||||
|
$seed->run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getSeedClasses(): array
|
||||||
|
{
|
||||||
|
$seedsFolder = implode(DIRECTORY_SEPARATOR, [__DIR__, 'Seeds']);
|
||||||
|
$files = new FilesystemIterator($seedsFolder, FilesystemIterator::SKIP_DOTS);
|
||||||
|
$seeds = [];
|
||||||
|
foreach ($files as $file) {
|
||||||
|
$seeds []= $this->buildClassName($file->getBasename('.php'));
|
||||||
|
}
|
||||||
|
return $seeds;
|
||||||
|
}
|
||||||
|
protected function getSeed(string $seedClassName): SeedInterface
|
||||||
|
{
|
||||||
|
return new $seedClassName($this->connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildClassName(string $fileBaseName): string
|
||||||
|
{
|
||||||
|
$namespace = implode('\\', [__NAMESPACE__, 'Seeds']);
|
||||||
|
return implode('\\', [$namespace, $fileBaseName]);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function orderedSeeds(array $seedClasses): array
|
||||||
|
{
|
||||||
|
$orderedSeeds = [];
|
||||||
|
foreach ($seedClasses as $seedClassName) {
|
||||||
|
$seed = $this->getSeed($seedClassName);
|
||||||
|
if ($seed->getDependencies() === []) {
|
||||||
|
$orderedSeeds[$seedClassName] = $seed;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$orderedSeeds = array_merge($orderedSeeds, $this->orderedDependencies($orderedSeeds, $seedClasses, $seedClassName));
|
||||||
|
}
|
||||||
|
return $orderedSeeds;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function orderedDependencies(array $orderedSeeds, array $seedClasses, string $seedClassName): array
|
||||||
|
{
|
||||||
|
$seed = $this->getSeed($seedClassName);
|
||||||
|
$dependencies = $seed->getDependencies();
|
||||||
|
foreach ($dependencies as $dependencyClass) {
|
||||||
|
if (!array_key_exists($dependencyClass, $orderedSeeds)) {
|
||||||
|
$orderedSeeds = array_merge($orderedSeeds, $this->orderedDependencies($orderedSeeds, $seedClasses, $dependencyClass));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!array_key_exists($seedClassName, $orderedSeeds)) {
|
||||||
|
$orderedSeeds[$seedClassName] = $seed;
|
||||||
|
}
|
||||||
|
return $orderedSeeds;
|
||||||
|
}
|
||||||
|
}
|
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
|
<?php
|
||||||
namespace Incoviba\Test\Integration;
|
namespace Incoviba\Test\Integration;
|
||||||
|
|
||||||
|
use DateInterval;
|
||||||
|
use DateTimeImmutable;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Faker;
|
use Faker;
|
||||||
|
use Incoviba\Common\Define;
|
||||||
use Incoviba\Common\Implement;
|
use Incoviba\Common\Implement;
|
||||||
use Incoviba\Common\Ideal;
|
use Incoviba\Common\Ideal;
|
||||||
use Incoviba\Service;
|
use Incoviba\Service;
|
||||||
use Incoviba\Repository;
|
use Incoviba\Repository;
|
||||||
|
use Tests\Extension\Faker\Provider\Rut;
|
||||||
|
|
||||||
class QueueTest extends TestCase
|
class QueueTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -22,6 +26,7 @@ class QueueTest extends TestCase
|
|||||||
public function testServiceWorker(): void
|
public function testServiceWorker(): void
|
||||||
{
|
{
|
||||||
$faker = Faker\Factory::create();
|
$faker = Faker\Factory::create();
|
||||||
|
$faker->addProvider(new Rut($faker));
|
||||||
$pagoData = [
|
$pagoData = [
|
||||||
'fecha' => '2022-01-01',
|
'fecha' => '2022-01-01',
|
||||||
'valor' => 10000,
|
'valor' => 10000,
|
||||||
@ -37,31 +42,65 @@ class QueueTest extends TestCase
|
|||||||
$pago = $pagoService->getById($pago->id);
|
$pago = $pagoService->getById($pago->id);
|
||||||
$this->assertNotEquals(0.0, $pago->uf);
|
$this->assertNotEquals(0.0, $pago->uf);
|
||||||
|
|
||||||
$comunaRepository = $this->container->get(Repository\Comuna::class);
|
$direccionRepository = $this->container->get(Repository\Direccion::class);
|
||||||
$comunas = $comunaRepository->fetchAll();
|
$direcciones = $direccionRepository->fetchAll();
|
||||||
$id = $faker->numberBetween(0, count($comunas) - 1);
|
$direccion = $faker->randomElement($direcciones);
|
||||||
$comuna = $comunas[$id];
|
$rut = $faker->rut(false, false);
|
||||||
$direccionData = [
|
|
||||||
'calle' => $faker->streetName,
|
|
||||||
'numero' => $faker->buildingNumber,
|
|
||||||
'comuna' => $comuna->id
|
|
||||||
];
|
|
||||||
$propietarioData = [
|
$propietarioData = [
|
||||||
'rut' => $faker->numberBetween(10000000, 99999999),
|
'rut' => $rut,
|
||||||
'nombre' => $faker->name,
|
'dv' => $faker->digitoVerificador($rut),
|
||||||
|
'direccion' => $direccion->id,
|
||||||
|
'nombres' => $faker->firstName,
|
||||||
'apellido_paterno' => $faker->lastName,
|
'apellido_paterno' => $faker->lastName,
|
||||||
'apellido_materno' => $faker->lastName,
|
'apellido_materno' => $faker->lastName,
|
||||||
|
'email' => $faker->email,
|
||||||
|
'telefono' => $faker->randomNumber(9),
|
||||||
];
|
];
|
||||||
$propietarioRepository = $this->container->get(Repository\Venta\Propietario::class);
|
$propietarioRepository = $this->container->get(Repository\Venta\Propietario::class);
|
||||||
$propietario = $propietarioRepository->create($propietarioData);
|
$propietario = $propietarioRepository->create($propietarioData);
|
||||||
$propietario = $propietarioRepository->save($propietario);
|
$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);
|
$propiedadRepository = $this->container->get(Repository\Venta\Propiedad::class);
|
||||||
$propiedad = $propiedadRepository->create();
|
$propiedad = $propiedadRepository->create($propiedadData);
|
||||||
$propiedad = $propiedadRepository->save($propiedad);
|
$propiedad = $propiedadRepository->save($propiedad);
|
||||||
|
$fecha = $faker->date;
|
||||||
$ventaData = [
|
$ventaData = [
|
||||||
'fecha' => '2022-01-01',
|
'fecha' => $fecha,
|
||||||
'propietario' => $propietario->rut,
|
'propietario' => $propietario->rut,
|
||||||
'propiedad' => $propiedad->id,
|
'propiedad' => $propiedad->id,
|
||||||
|
'fecha_ingreso' => new DateTimeImmutable($fecha)->add(new DateInterval('P3D'))->format('Y-m-d'),
|
||||||
];
|
];
|
||||||
$ventaRepository = $this->container->get(Repository\Venta::class);
|
$ventaRepository = $this->container->get(Repository\Venta::class);
|
||||||
$venta = $ventaRepository->create($ventaData);
|
$venta = $ventaRepository->create($ventaData);
|
||||||
@ -83,4 +122,4 @@ class QueueTest extends TestCase
|
|||||||
$cuota = $cuotaService->getById($cuota->id);
|
$cuota = $cuotaService->getById($cuota->id);
|
||||||
$this->assertNotEquals(0.0, $cuota->pago->uf);
|
$this->assertNotEquals(0.0, $cuota->pago->uf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
3
bin/test-app.bat
Normal file
3
bin/test-app.bat
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@echo off
|
||||||
|
|
||||||
|
docker compose --profile testing run --rm -it testing bin/phpunit %*
|
Reference in New Issue
Block a user