DITestCase::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Faxity\Test;
4
5
use Anax\DI\DIMagic;
6
use Anax\DI\DI;
7
8
/**
9
 * Just a wrapper so we dont need to add same code in all
10
 * of the DI tests
11
 */
12
class DITestCase extends \PHPUnit\Framework\TestCase
13
{
14
    /** @var DI $di Dependency injector */
15
    protected $di;
16
17
18
    /**
19
     * Creates a DI handler for this test case, by default uses DIMagic.
20
     *
21
     * @return DI
22
     */
23 22
    protected function createDI(): DI
24
    {
25
        // Create dependency injector with the service
26 22
        $di = new DIMagic();
27 22
        $di->loadServices(ANAX_INSTALL_PATH . "/config/di");
28 22
        $di->loadServices(ANAX_INSTALL_PATH . "/test/config/di");
29
30 22
        return $di;
31
    }
32
33
34
    /**
35
     * Setup for every test case
36
     *
37
     * @return void
38
     */
39 22
    public function setUp(): void
40
    {
41 22
        global $di;
42
43 22
        $di = $this->createDI();
44 22
        $this->di = $di;
45 22
    }
46
47
48
    /**
49
     * Teardown for every test case
50
     *
51
     * @return void
52
     */
53 22
    public function tearDown(): void
54
    {
55 22
        global $di;
56
57 22
        $di = null;
58 22
        $this->di = null;
59 22
    }
60
}
61