Completed
Push — master ( 0852eb...5dead4 )
by Christopher
03:02
created

TestCase   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 7
dl 0
loc 43
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareTestRoot() 0 6 1
A reloadConfig() 0 4 1
A setUp() 0 11 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\Cache\Clearer;
8
use Phwoolcon\Config;
9
use Phwoolcon\Log;
10
use Phwoolcon\Util\Timer;
11
12
class TestCase extends PhpunitTestCase
13
{
14
    use RemoteCoverageTrait;
15
16
    /**
17
     * @var Di
18
     */
19
    protected $di;
20
21 1
    protected function prepareTestRoot($testRootReady)
22
    {
23 1
        $assembler = new ResourceAggregator(getcwd());
24 1
        $assembler->aggregate();
25 1
        touch($testRootReady);
26 1
    }
27
28
    /**
29
     * @codeCoverageIgnore
30
     */
31
    protected function reloadConfig()
32
    {
33
        Config::register($this->di);
34
    }
35
36 2
    public function setUp()
37
    {
38 2
        is_file($testRootReady = TEST_ROOT_PATH . '/ready') || $this->prepareTestRoot($testRootReady);
39 2
        $di = Di::getDefault();
40 2
        include TEST_ROOT_PATH . '/vendor/phwoolcon/di.php';
41 2
        $this->di = $di;
42 2
        Clearer::clear();
43 2
        $class = get_class($this);
44 2
        Log::debug("================== Running {$class}::{$this->getName()}() ... ==================");
45 2
        Timer::start();
46 2
    }
47
48 2
    public function tearDown()
49
    {
50 2
        $elapsed = Timer::stop();
51 2
        parent::tearDown();
52 2
        Log::debug("================== Finished, time elapsed: {$elapsed}. ==================");
53 2
    }
54
}
55