Passed
Push — main ( e3dcf6...088d44 )
by Osvaldo
01:32
created

ElementosTest   A

Complexity

Total Complexity 25

Size/Duplication

Total Lines 219
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 75
c 2
b 0
f 0
dl 0
loc 219
rs 10
wmc 25

25 Methods

Rating   Name   Duplication   Size   Complexity  
A testElComparadorSoloPuedeSerLogico() 0 4 1
A testDondeYDondeConOrdenYLimiteRetornaString() 0 14 1
A testSiElCampoEstaVacioLanzaExcepcion() 0 4 1
A testSiLaTablaEstaVaciaLanzaExcepcion() 0 4 1
A testLosDatosQueDevuelveYDondeSiempreSonArray() 0 7 1
A testYDondeSoloRetornaTexto() 0 8 1
A testLosDatosQueDevuelveSiempreSonArray() 0 4 1
A testLosDatosQueDevuelveEntreSiempreSonArray() 0 4 1
A testDondeOEntreConOrdenYLimiteRetornaString() 0 11 1
A testLosDatosQueDevuelveODondeSiempreSonArray() 0 7 1
A testLaSentenciaOrdenNoPuedeEstarVacia() 0 4 1
A testLaSentenciaOrdenSoloPiedeRetornarString() 0 4 1
A testCamposSoloRetornaTexto() 0 4 1
A testLaSentenciaLimiteNoPuedeEstarVacia() 0 4 1
A testSiEntreEstaVacioLanzaExcepcion() 0 4 1
A testDondeYDondeConParametroRetornaString() 0 11 1
A testDondeOEntreConParametroRetornaString() 0 8 1
A testLaSentenciaLimiteSoloAceptaValoresNumero() 0 4 1
A testOrdenYLimiteRetornaString() 0 4 1
A testLaSentenciaLimiteSoloPuedeRetornarString() 0 4 1
A testDondeSoloRetornaTexto() 0 4 1
A testEntreSoloRetornaTexto() 0 4 1
A testODondeSoloRetornaTexto() 0 8 1
A testTablaSoloRetornaTexto() 0 4 1
A testSiDondeEstaVacioLanzaExcepcion() 0 4 1
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\DondeOEntreConOrdenYLimite;
10
use src\pdodatabase\elementos\DondeOEntreConParametro;
11
use src\pdodatabase\elementos\DondeYDondeConOrdenYLimite;
12
use src\pdodatabase\elementos\DondeYDondeConParametro;
13
use src\pdodatabase\elementos\Entre;
14
use src\pdodatabase\elementos\Limite;
15
use src\pdodatabase\elementos\ODonde;
16
use src\pdodatabase\elementos\Orden;
17
use src\pdodatabase\elementos\Tabla;
18
use src\pdodatabase\elementos\YDonde;
19
use src\pdodatabase\elementos\OrdenConLimite;
20
21
22
class ElementosTest extends TestCase
23
{
24
    //Tabla
25
26
    public function testSiLaTablaEstaVaciaLanzaExcepcion()
27
    {
28
        $this->expectException(Exception::class);
29
        $tabla = new Tabla('');
0 ignored issues
show
Unused Code introduced by
The assignment to $tabla is dead and can be removed.
Loading history...
30
    }
31
32
    public function testTablaSoloRetornaTexto()
33
    {
34
        $tabla = new Tabla('Hola');
35
        $this->assertIsString($tabla->tabla());
36
    }
37
38
    //Campos
39
40
    public function testSiElCampoEstaVacioLanzaExcepcion()
41
    {
42
        $this->expectException(Exception::class);
43
        $campos = new Campos([]);
0 ignored issues
show
Unused Code introduced by
The assignment to $campos is dead and can be removed.
Loading history...
44
    }
45
46
    public function testCamposSoloRetornaTexto()
47
    {
48
        $campos = new Campos(['*','78']);
49
        $this->assertIsString($campos->campos());
50
    }
51
52
    //Donde
53
54
    public function testSiDondeEstaVacioLanzaExcepcion()
55
    {
56
        $this->expectException(Exception::class);
57
        $donde = new Donde([]);
0 ignored issues
show
Unused Code introduced by
The assignment to $donde is dead and can be removed.
Loading history...
58
    }
59
60
    public function testDondeSoloRetornaTexto()
61
    {
62
        $donde = new Donde(['id','=','23']);
63
        $this->assertIsString($donde->donde());
64
    }
65
66
    public function testElComparadorSoloPuedeSerLogico()
67
    {
68
        $this->expectException(Exception::class);
69
        $donde = new Donde(['id','12','23']);
0 ignored issues
show
Unused Code introduced by
The assignment to $donde is dead and can be removed.
Loading history...
70
    }
71
72
    public function testLosDatosQueDevuelveSiempreSonArray()
73
    {
74
        $donde = new Donde(['id','=','1']);
75
        $this->assertIsArray($donde->datos());
76
    }
77
78
    //Entre
79
80
    public function testSiEntreEstaVacioLanzaExcepcion()
81
    {
82
        $this->expectException(Exception::class);
83
        $Entre = new Entre([]);
0 ignored issues
show
Unused Code introduced by
The assignment to $Entre is dead and can be removed.
Loading history...
84
    }
85
86
    public function testEntreSoloRetornaTexto()
87
    {
88
        $Entre = new Entre(['id','45','23']);
89
        $this->assertIsString($Entre->donde());
90
    }
91
92
    public function testLosDatosQueDevuelveEntreSiempreSonArray()
93
    {
94
        $donde = new Entre(['id','1','1']);
95
        $this->assertIsArray($donde->datos());
96
    }
97
98
    //ODonde
99
100
    public function testODondeSoloRetornaTexto()
101
    {
102
        $ODonde = new ODonde(
103
            new Donde(['id','=','1']),
104
            new Donde(['id','=','2'])
105
        );
106
107
        $this->assertIsString($ODonde->donde());
108
    }
109
110
    public function testLosDatosQueDevuelveODondeSiempreSonArray()
111
    {
112
        $donde = new ODonde(
113
            new Donde(['id','=','1']),
114
            new Donde(['id','=','2'])
115
        );
116
        $this->assertIsArray($donde->datos());
117
    }
118
119
    //YDonde
120
121
122
    public function testYDondeSoloRetornaTexto()
123
    {
124
        $YDonde = new YDonde(
125
            new Donde(['id','=','1']),
126
            new Donde(['id','=','2'])
127
        );
128
129
        $this->assertIsString($YDonde->donde());
130
    }
131
132
    public function testLosDatosQueDevuelveYDondeSiempreSonArray()
133
    {
134
        $donde = new YDonde(
135
            new Donde(['id','=','1']),
136
            new Donde(['id','=','2'])
137
        );
138
        $this->assertIsArray($donde->datos());
139
    }
140
141
    //Orden
142
143
    public function testLaSentenciaOrdenNoPuedeEstarVacia()
144
    {
145
        $this->expectException(Exception::class);
146
        $orden = new Orden('');
0 ignored issues
show
Unused Code introduced by
The assignment to $orden is dead and can be removed.
Loading history...
147
    }
148
149
    public function testLaSentenciaOrdenSoloPiedeRetornarString()
150
    {
151
        $orden = new Orden('id');
152
        $this->assertIsString($orden->parametro());
153
    }
154
155
    //Limite
156
157
    public function testLaSentenciaLimiteNoPuedeEstarVacia()
158
    {
159
        $this->expectException(Exception::class);
160
        $orden = new Limite('');
0 ignored issues
show
Unused Code introduced by
The assignment to $orden is dead and can be removed.
Loading history...
161
    }
162
163
    public function testLaSentenciaLimiteSoloAceptaValoresNumero()
164
    {
165
        $this->expectException(Exception::class);
166
        $orden = new Limite('a');
0 ignored issues
show
Unused Code introduced by
The assignment to $orden is dead and can be removed.
Loading history...
167
    }
168
169
    public function testLaSentenciaLimiteSoloPuedeRetornarString()
170
    {
171
        $orden = new Limite('1');
172
        $this->assertIsString($orden->parametro());
173
    }
174
175
    //orden y limite
176
177
    public function testOrdenYLimiteRetornaString()
178
    {
179
        $consulta = new OrdenConLimite(new Orden('id'), new Limite('1'));
180
        $this->assertIsString($consulta->parametro());
181
    }
182
183
    //Donde o Entre con parametro
184
185
    public function testDondeOEntreConParametroRetornaString()
186
    {
187
        $consulta = new DondeOEntreConParametro(
188
            new Donde(['id','=',1]),
189
            new Limite('1')
190
        );
191
192
        $this->assertIsString($consulta->donde());
193
    }
194
195
    //donde o entre con orden y limite
196
197
    public function testDondeOEntreConOrdenYLimiteRetornaString()
198
    {
199
        $consulta = new DondeOEntreConOrdenYLimite(
200
            new Donde(['id','=',1]),
201
            new OrdenConLimite(
202
                new Orden('id'),
203
                new Limite('1')
204
            )
205
        );
206
207
        $this->assertIsString($consulta->donde());
208
    }
209
210
    // donde y donde con parametro
211
212
    public function testDondeYDondeConParametroRetornaString()
213
    {
214
        $consulta = new DondeYDondeConParametro(
215
            new YDonde(
216
            new Donde(['id','=',1]),
217
            new Donde(['id','=',1])
218
            ),
219
            new Limite('1')
220
        );
221
222
        $this->assertIsString($consulta->donde());
223
    }
224
225
    //donde o entre con orden y limite
226
227
    public function testDondeYDondeConOrdenYLimiteRetornaString()
228
    {
229
        $consulta = new DondeYDondeConOrdenYLimite(
230
            new YDonde(
231
                new Donde(['id','=',1]),
232
                new Donde(['id','=',1])
233
                ),
234
            new OrdenConLimite(
235
                new Orden('id'),
236
                new Limite('1')
237
            )
238
        );
239
240
        $this->assertIsString($consulta->donde());
241
    }
242
}