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

DITestCase::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 12
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
use Anax\Commons\ContainerInjectableInterface;
8
9
/**
10
 * Just a wrapper so we dont need to add same code in all
11
 * of the controllers test classes
12
 */
13
abstract class DITestCase extends TestCase
14
{
15
    /**
16
     * @var $service DI service
0 ignored issues
show
Documentation Bug introduced by
The doc comment $service at position 0 could not be parsed: Unknown type name '$service' at position 0 in $service.
Loading history...
17
     * @var $di Dependency injector
18
     */
19
    protected $service;
20
    protected $di;
21
22
23
    abstract protected function createService() : ContainerInjectableInterface;
24
25
26
    /**
27
     * Setup for every test case
28
     * @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...
29
     */
30
    public function setUp() : void
31
    {
32
        global $di;
33
34
        // Create dependency injector with the service
35
        $di = new DIMagic();
36
        $di->loadServices(ANAX_INSTALL_PATH . "/config/di");
37
        $di->loadServices(ANAX_INSTALL_PATH . "/test/config/di");
38
39
        $this->di = $di;
40
        $this->service = $this->createService();
41
        $this->service->setDI($di);
42
    }
43
44
45
    /**
46
     * Teardown for every test case
47
     * @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...
48
     */
49
    public function tearDown() : void
50
    {
51
        global $di;
52
53
        $di = null;
54
        $this->service = null;
55
        $this->di = null;
56
    }
57
}
58