Test Failed
Branch v0.2 (3f77aa)
by Freddie
07:42 queued 01:11
created

FunctionalTest   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFromContainer() 0 3 1
A tearDown() 0 7 1
A setUp() 0 8 2
A setInContainer() 0 3 1
A getContainer() 0 8 2
1
<?php declare(strict_types=1);
2
3
namespace Simplex\Quickstart\Shared\Testing;
4
5
use DI\Container;
6
use Helmich\JsonAssert\JsonAssertions;
7
use Helmich\Psr7Assert\Psr7Assertions;
8
use Mockery as m;
9
use PHPUnit\Framework\TestCase;
10
use Simplex\Bootstrap;
11
12
class FunctionalTest extends TestCase
13
{
14
    use HttpRequestCapabilities;
15
    use JsonAssertions;
16
    use Psr7Assertions;
17
18
    const CONFIG_DIRECTORY_PATH = __DIR__ . '/../../../config';
19
20
    protected $reloadDb = true;
21
22
    /** @var Container */
23
    private static $container;
24
25
    protected function setUp()
26
    {
27
        if ($this->reloadDb) {
28
            $loader = $this->getContainer()->get(FixtureLoader::class);
29
            $loader->load();
30
        }
31
32
        parent::setUp();
33
    }
34
35
    protected function tearDown()
36
    {
37
        m::close();
38
39
        $this->reloadDb = true;
40
41
        parent::tearDown();
42
    }
43
44
    public function getFromContainer(string $id)
45
    {
46
        return $this->getContainer()->get($id);
47
    }
48
49
    public function getContainer(): Container
50
    {
51
        if (!isset(self::$container)) {
52
            Bootstrap::init(self::CONFIG_DIRECTORY_PATH);
53
            self::$container = Bootstrap::getContainer();
54
        }
55
56
        return self::$container;
57
    }
58
59
    public function setInContainer($name, $value): void
60
    {
61
        $this->getContainer()->set($name, $value);
62
    }
63
}
64