Test Failed
Push — master ( e1d1d3...496a95 )
by Christian
01:54
created

ControllerTestCase::tearDown()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Faxity\Test;
4
5
use Anax\DI\DIMagic;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * Just a wrapper so we dont need to add same code in all
10
 * of the controllers test classes
11
 */
12
class ControllerTestCase extends TestCase
13
{
14
    /**
15
     * @var $controller Anax Controller class
0 ignored issues
show
Documentation Bug introduced by
The doc comment $controller at position 0 could not be parsed: Unknown type name '$controller' at position 0 in $controller.
Loading history...
16
     * @var $di Dependency injector
17
     * @var $className Controller class name
18
     */
19
    protected $controller;
20
    protected $di;
21
    protected $className;
22
23
    /**
24
     * Setup for every test case
25
     * @return void.
0 ignored issues
show
Documentation Bug introduced by
The doc comment void. at position 0 could not be parsed: Unknown type name 'void.' at position 0 in void..
Loading history...
26
     */
27
    public function setUp() : void
28
    {
29
        global $di;
30
31
        // Create dependency injector with the controller
32
        $di = new DIMagic();
33
        $di->loadServices(ANAX_INSTALL_PATH . "/config/di");
34
        $di->loadServices(ANAX_INSTALL_PATH . "/test/config/di");
35
36
        $controllerClass = $this->className;
37
        $controller = new $controllerClass();
38
        $controller->setDI($di);
39
40
        if (method_exists($controller, "initialize")) {
41
            $controller->initialize();
42
        }
43
44
        $this->di = $di;
45
        $this->controller = $controller;
46
    }
47
48
    /**
49
     * Teardown for every test case
50
     * @return void.
0 ignored issues
show
Documentation Bug introduced by
The doc comment void. at position 0 could not be parsed: Unknown type name 'void.' at position 0 in void..
Loading history...
51
     */
52
    public function tearDown() : void
53
    {
54
        global $di;
55
56
        $di = null;
57
        $this->controller = null;
58
        $this->di = null;
59
    }
60
}
61