|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
namespace test; |
|
4
|
|
|
|
|
5
|
|
|
use Exception; |
|
6
|
|
|
use \PHPUnit\Framework\TestCase; |
|
7
|
|
|
use src\pdodatabase\elementos\Campos; |
|
8
|
|
|
use src\pdodatabase\elementos\Donde; |
|
9
|
|
|
use src\pdodatabase\elementos\Entre; |
|
10
|
|
|
use src\pdodatabase\elementos\Limite; |
|
11
|
|
|
use src\pdodatabase\elementos\ODonde; |
|
12
|
|
|
use src\pdodatabase\elementos\Orden; |
|
13
|
|
|
use src\pdodatabase\elementos\Tabla; |
|
14
|
|
|
use src\pdodatabase\elementos\YDonde; |
|
15
|
|
|
|
|
16
|
|
|
class ElementosTest extends TestCase |
|
17
|
|
|
{ |
|
18
|
|
|
//Tabla |
|
19
|
|
|
|
|
20
|
|
|
public function testSiLaTablaEstaVaciaLanzaExcepcion() |
|
21
|
|
|
{ |
|
22
|
|
|
$this->expectException(Exception::class); |
|
23
|
|
|
$tabla = new Tabla(''); |
|
|
|
|
|
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testTablaSoloRetornaTexto() |
|
27
|
|
|
{ |
|
28
|
|
|
$tabla = new Tabla('Hola'); |
|
29
|
|
|
$this->assertIsString($tabla->tabla()); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
//Campos |
|
33
|
|
|
|
|
34
|
|
|
public function testSiElCampoEstaVacioLanzaExcepcion() |
|
35
|
|
|
{ |
|
36
|
|
|
$this->expectException(Exception::class); |
|
37
|
|
|
$campos = new Campos([]); |
|
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function testCamposSoloRetornaTexto() |
|
41
|
|
|
{ |
|
42
|
|
|
$campos = new Campos(['*','78']); |
|
43
|
|
|
$this->assertIsString($campos->campos()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
//Donde |
|
47
|
|
|
|
|
48
|
|
|
public function testSiDondeEstaVacioLanzaExcepcion() |
|
49
|
|
|
{ |
|
50
|
|
|
$this->expectException(Exception::class); |
|
51
|
|
|
$donde = new Donde([]); |
|
|
|
|
|
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function testDondeSoloRetornaTexto() |
|
55
|
|
|
{ |
|
56
|
|
|
$donde = new Donde(['id','=','23']); |
|
57
|
|
|
$this->assertIsString($donde->donde()); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
public function testElComparadorSoloPuedeSerLogico() |
|
61
|
|
|
{ |
|
62
|
|
|
$this->expectException(Exception::class); |
|
63
|
|
|
$donde = new Donde(['id','12','23']); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
public function testLosDatosQueDevuelveSiempreSonArray() |
|
67
|
|
|
{ |
|
68
|
|
|
$donde = new Donde(['id','=','1']); |
|
69
|
|
|
$this->assertIsArray($donde->datos()); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
//Entre |
|
73
|
|
|
|
|
74
|
|
|
public function testSiEntreEstaVacioLanzaExcepcion() |
|
75
|
|
|
{ |
|
76
|
|
|
$this->expectException(Exception::class); |
|
77
|
|
|
$Entre = new Entre([]); |
|
|
|
|
|
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
public function testEntreSoloRetornaTexto() |
|
81
|
|
|
{ |
|
82
|
|
|
$Entre = new Entre(['id','45','23']); |
|
83
|
|
|
$this->assertIsString($Entre->donde()); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function testLosDatosQueDevuelveEntreSiempreSonArray() |
|
87
|
|
|
{ |
|
88
|
|
|
$donde = new Entre(['id','1','1']); |
|
89
|
|
|
$this->assertIsArray($donde->datos()); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
//ODonde |
|
93
|
|
|
|
|
94
|
|
|
public function testODondeSoloRetornaTexto() |
|
95
|
|
|
{ |
|
96
|
|
|
$ODonde = new ODonde( |
|
97
|
|
|
new Donde(['id','=','1']), |
|
98
|
|
|
new Donde(['id','=','2']) |
|
99
|
|
|
); |
|
100
|
|
|
|
|
101
|
|
|
$this->assertIsString($ODonde->donde()); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
public function testLosDatosQueDevuelveODondeSiempreSonArray() |
|
105
|
|
|
{ |
|
106
|
|
|
$donde = new ODonde( |
|
107
|
|
|
new Donde(['id','=','1']), |
|
108
|
|
|
new Donde(['id','=','2']) |
|
109
|
|
|
); |
|
110
|
|
|
$this->assertIsArray($donde->datos()); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
//YDonde |
|
114
|
|
|
|
|
115
|
|
|
|
|
116
|
|
|
public function testYDondeSoloRetornaTexto() |
|
117
|
|
|
{ |
|
118
|
|
|
$YDonde = new YDonde( |
|
119
|
|
|
new Donde(['id','=','1']), |
|
120
|
|
|
new Donde(['id','=','2']) |
|
121
|
|
|
); |
|
122
|
|
|
|
|
123
|
|
|
$this->assertIsString($YDonde->donde()); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
public function testLosDatosQueDevuelveYDondeSiempreSonArray() |
|
127
|
|
|
{ |
|
128
|
|
|
$donde = new YDonde( |
|
129
|
|
|
new Donde(['id','=','1']), |
|
130
|
|
|
new Donde(['id','=','2']) |
|
131
|
|
|
); |
|
132
|
|
|
$this->assertIsArray($donde->datos()); |
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
//Orden |
|
136
|
|
|
|
|
137
|
|
|
public function testLaSentenciaOrdenNoPuedeEstarVacia() |
|
138
|
|
|
{ |
|
139
|
|
|
$this->expectException(Exception::class); |
|
140
|
|
|
$orden = new Orden(''); |
|
|
|
|
|
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function testLaSentenciaOrdenSoloPiedeRetornarString() |
|
144
|
|
|
{ |
|
145
|
|
|
$orden = new Orden('id'); |
|
146
|
|
|
$this->assertIsString($orden->parametro()); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
//Limite |
|
150
|
|
|
|
|
151
|
|
|
public function testLaSentenciaLimiteNoPuedeEstarVacia() |
|
152
|
|
|
{ |
|
153
|
|
|
$this->expectException(Exception::class); |
|
154
|
|
|
$orden = new Limite(''); |
|
|
|
|
|
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
public function testLaSentenciaLimiteSoloAceptaValoresNumero() |
|
158
|
|
|
{ |
|
159
|
|
|
$this->expectException(Exception::class); |
|
160
|
|
|
$orden = new Limite('a'); |
|
|
|
|
|
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
public function testLaSentenciaLimiteSoloPuedeRetornarString() |
|
164
|
|
|
{ |
|
165
|
|
|
$orden = new Limite('1'); |
|
166
|
|
|
$this->assertIsString($orden->parametro()); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
} |