Passed
Push — main ( f2df15...8d7bb5 )
by Osvaldo
09:13
created

testSiElCampoEstaVacioLanzaExcepcion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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('');
0 ignored issues
show
Unused Code introduced by
The assignment to $tabla is dead and can be removed.
Loading history...
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([]);
0 ignored issues
show
Unused Code introduced by
The assignment to $campos is dead and can be removed.
Loading history...
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([]);
0 ignored issues
show
Unused Code introduced by
The assignment to $donde is dead and can be removed.
Loading history...
52
    }
53
54
    public function testDondeSoloRetornaTexto()
55
    {
56
        $donde = new Donde(['id','=','23']);
57
        $this->assertIsString($donde->donde());
58
    }
59
60
    public function testLaColumnaSoloPuedeSerAlfaNumerica()
61
    {
62
        $this->expectException(Exception::class);
63
        $donde = new Donde(['%','=',2]);
0 ignored issues
show
Unused Code introduced by
The assignment to $donde is dead and can be removed.
Loading history...
64
    }
65
66
    public function testElValorSoloPuedeSerAlfaNumerico()
67
    {
68
        $this->expectException(Exception::class);
69
        $donde = new Donde(['id','=','#']);
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 testElComparadorSoloPuedeSerLogico()
73
    {
74
        $this->expectException(Exception::class);
75
        $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...
76
    }
77
78
    public function testLosDatosQueDevuelveSiempreSonArray()
79
    {
80
        $donde = new Donde(['id','=','1']);
81
        $this->assertIsArray($donde->datos());
82
    }
83
84
    //Entre
85
86
    public function testSiEntreEstaVacioLanzaExcepcion()
87
    {
88
        $this->expectException(Exception::class);
89
        $Entre = new Entre([]);
0 ignored issues
show
Unused Code introduced by
The assignment to $Entre is dead and can be removed.
Loading history...
90
    }
91
92
    public function testEntreSoloRetornaTexto()
93
    {
94
        $Entre = new Entre(['id','45','23']);
95
        $this->assertIsString($Entre->donde());
96
    }
97
98
    public function testLosDatosQueDevuelveEntreSiempreSonArray()
99
    {
100
        $donde = new Entre(['id','1','1']);
101
        $this->assertIsArray($donde->datos());
102
    }
103
104
    public function testLaColumnaDeEntreSoloPuedeSerAlfaNumerica()
105
    {
106
        $this->expectException(Exception::class);
107
        $donde = new Entre(['=','1','1']);
0 ignored issues
show
Unused Code introduced by
The assignment to $donde is dead and can be removed.
Loading history...
108
    }
109
110
    public function testElPrimeroValorDeEntreSoloPuedeSerAlfaNumerico()
111
    {
112
        $this->expectException(Exception::class);
113
        $donde = new Entre(['id','=','1']);
0 ignored issues
show
Unused Code introduced by
The assignment to $donde is dead and can be removed.
Loading history...
114
    }
115
116
    public function testElSegundoValorDeEntreSoloPuedeSerAlfaNumerico()
117
    {
118
        $this->expectException(Exception::class);
119
        $donde = new Entre(['id','1','&']);
0 ignored issues
show
Unused Code introduced by
The assignment to $donde is dead and can be removed.
Loading history...
120
    }
121
122
    //ODonde
123
124
    public function testODondeSoloRetornaTexto()
125
    {
126
        $ODonde = new ODonde(
127
            new Donde(['id','=','1']),
128
            new Donde(['id','=','2'])
129
        );
130
131
        $this->assertIsString($ODonde->donde());
132
    }
133
134
    public function testLosDatosQueDevuelveODondeSiempreSonArray()
135
    {
136
        $donde = new ODonde(
137
            new Donde(['id','=','1']),
138
            new Donde(['id','=','2'])
139
        );
140
        $this->assertIsArray($donde->datos());
141
    }
142
143
    //YDonde
144
145
146
    public function testYDondeSoloRetornaTexto()
147
    {
148
        $YDonde = new YDonde(
149
            new Donde(['id','=','1']),
150
            new Donde(['id','=','2'])
151
        );
152
153
        $this->assertIsString($YDonde->donde());
154
    }
155
156
    public function testLosDatosQueDevuelveYDondeSiempreSonArray()
157
    {
158
        $donde = new YDonde(
159
            new Donde(['id','=','1']),
160
            new Donde(['id','=','2'])
161
        );
162
        $this->assertIsArray($donde->datos());
163
    }
164
165
    //Orden
166
167
    public function testLaSentenciaOrdenNoPuedeEstarVacia()
168
    {
169
        $this->expectException(Exception::class);
170
        $orden = new Orden('');
0 ignored issues
show
Unused Code introduced by
The assignment to $orden is dead and can be removed.
Loading history...
171
    }
172
173
    public function testLaSenetenciaOrdenSoloPuedeSerAlfanumerica()
174
    {
175
        $this->expectException(Exception::class);
176
        $orden = new Orden('$');
0 ignored issues
show
Unused Code introduced by
The assignment to $orden is dead and can be removed.
Loading history...
177
    }
178
179
    public function testLaSentenciaOrdenSoloPiedeRetornarString()
180
    {
181
        $orden = new Orden('id');
182
        $this->assertIsString($orden->parametro());
183
    }
184
185
    //Limite
186
187
    public function testLaSentenciaLimiteNoPuedeEstarVacia()
188
    {
189
        $this->expectException(Exception::class);
190
        $orden = new Limite('');
0 ignored issues
show
Unused Code introduced by
The assignment to $orden is dead and can be removed.
Loading history...
191
    }
192
193
    public function testLaSentenciaLimiteSoloAceptaValoresNumero()
194
    {
195
        $this->expectException(Exception::class);
196
        $orden = new Limite('a');
0 ignored issues
show
Unused Code introduced by
The assignment to $orden is dead and can be removed.
Loading history...
197
    }
198
199
    public function testLaSentenciaLimiteSoloPuedeRetornarString()
200
    {
201
        $orden = new Limite('1');
202
        $this->assertIsString($orden->parametro());
203
    }
204
205
}