Completed
Push — master ( 3ee08d...42539a )
by Christopher
02:21
created

TestCase   B

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 16

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 16
dl 0
loc 52
rs 8.4614
c 0
b 0
f 0
ccs 32
cts 32
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareTestRoot() 0 6 1
A reloadConfig() 0 4 1
A setUp() 0 23 2
A tearDown() 0 6 1
1
<?php
2
3
namespace Phwoolcon\TestStarter;
4
5
use Phalcon\Di;
6
use PHPUnit\Framework\TestCase as PhpunitTestCase;
7
use Phwoolcon\Aliases;
8
use Phwoolcon\Cache;
9
use Phwoolcon\Cache\Clearer;
10
use Phwoolcon\Config;
11
use Phwoolcon\Cookies;
12
use Phwoolcon\Db;
13
use Phwoolcon\DiFix;
14
use Phwoolcon\Events;
15
use Phwoolcon\I18n;
16
use Phwoolcon\Log;
17
use Phwoolcon\Session;
18
use Phwoolcon\Util\Counter;
19
use Phwoolcon\Util\Timer;
20
21
class TestCase extends PhpunitTestCase
22
{
23
    use RemoteCoverageTrait;
24
25
    /**
26
     * @var Di
27
     */
28
    protected $di;
29
30 1
    protected function prepareTestRoot($testRootReady)
31
    {
32 1
        $assembler = new ResourceAggregator(getcwd());
33 1
        $assembler->aggregate();
34 1
        touch($testRootReady);
35 1
    }
36
37 2
    protected function reloadConfig()
38
    {
39 2
        Config::register($this->di);
40 2
    }
41
42 2
    public function setUp()
43
    {
44 2
        is_file($testRootReady = TEST_ROOT_PATH . '/ready') || $this->prepareTestRoot($testRootReady);
45
46
        /* @var Di $di */
47 2
        $di = $this->di = Di::getDefault();
48 2
        Events::register($di);
49 2
        DiFix::fix($di);
50 2
        Db::register($di);
51 2
        Cache::register($di);
52 2
        Log::register($di);
53 2
        $this->reloadConfig();
54 2
        Counter::register($this->di);
55 2
        Aliases::register($di);
56 2
        I18n::register($di);
57 2
        Cookies::register($di);
58 2
        Session::register($di);
59 2
        Clearer::clear();
60
61 2
        $class = get_class($this);
62 2
        Log::debug("================== Running {$class}::{$this->getName()}() ... ==================");
63 2
        Timer::start();
64 2
    }
65
66 2
    public function tearDown()
67
    {
68 2
        $elapsed = Timer::stop();
69 2
        parent::tearDown();
70 2
        Log::debug("================== Finished, time elapsed: {$elapsed}. ==================");
71 2
    }
72
}
73