Issues (8)

tests/PeticionTest.php (8 issues)

1
<?php
2
namespace tests;
3
4
use PHPUnit\Framework\TestCase;
5
use src\Controlador;
6
use src\Enlace;
7
use src\Metodo;
8
use src\Parametros;
9
use src\Peticion;
10
11
define('CONTROLADOR_POR_DEFECTO','Controlador');
12
define('CONTROLADOR_DIR','controladores/');
13
define('CONTROLADOR_NAMESPACE', 'controladores\\');
14
define('METODO_POR_DEFECTO','index');
15
16
class PeticionTest extends TestCase
17
{
18
    public function setUp(): void
19
    {
20
        $this->e = new Enlace(['Controlador']);
0 ignored issues
show
Bug Best Practice introduced by
The property e does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
21
        $this->c = new Controlador($this->e);
0 ignored issues
show
Bug Best Practice introduced by
The property c does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
22
        $this->m = new Metodo($this->e,$this->c);
0 ignored issues
show
Bug Best Practice introduced by
The property m does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
        $this->p = new Parametros($this->e,$this->m);
0 ignored issues
show
Bug Best Practice introduced by
The property p does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
24
    }
25
26
    //Peticion
27
28
    public function testPeticionDevuelvecontroladorCorrecto()
29
    {
30
        $p = new Peticion($this->c, $this->m, $this->p);
31
        $this->assertSame('Controlador', $p->controlador());
32
    }
33
34
    public function testPeticionDevuelvecontroladorPorDefectoSiNoExisteElLlamado()
35
    {
36
        $this->e = new Enlace(['Iniciosssssssss']);
0 ignored issues
show
Bug Best Practice introduced by
The property e does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
37
        $this->c = new Controlador($this->e);
0 ignored issues
show
Bug Best Practice introduced by
The property c does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
38
        $this->m = new Metodo($this->e,$this->c);
0 ignored issues
show
Bug Best Practice introduced by
The property m does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
39
        $this->p = new Parametros($this->e,$this->m);
0 ignored issues
show
Bug Best Practice introduced by
The property p does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
40
        $p = new Peticion($this->c, $this->m, $this->p);
41
        $this->assertSame('Controlador', $p->controlador());
42
    }
43
44
    public function testPeticionDevuelveMetodoCorrecto()
45
    {
46
        $p = new Peticion($this->c, $this->m, $this->p);
47
        $this->assertSame('index', $p->metodo());
48
    }
49
50
    public function testPeticionDevuelveParametrosEnArray()
51
    {
52
        $p = new Peticion($this->c, $this->m, $this->p);
53
        $this->assertIsArray($p->parametros());
54
    }
55
56
    //Enlace
57
58
    public function testEnlaceSiempreRetornaUnArray()
59
    {
60
        $e = new Enlace([]);
61
        $this->assertIsArray($e->enlace());
62
        $e = new Enlace(['hola','hola2']);
63
        $this->assertIsArray($e->enlace());
64
    }
65
66
    //Controlador
67
68
    
69
70
71
    //Metodo
72
73
74
    //Parametros
75
}