TestCase   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 7
dl 0
loc 46
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A prepareTestRoot() 0 7 1
A reloadConfig() 0 4 1
A setUp() 0 13 4
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
        return $assembler;
27
    }
28
29
    /**
30
     * @codeCoverageIgnore
31
     */
32
    protected function reloadConfig()
33
    {
34
        Config::register($this->di);
35
    }
36
37 2
    public function setUp()
38
    {
39 2
        $firstRun = !is_file($testRootReady = TEST_ROOT_PATH . '/ready');
40 2
        $firstRun && $assembler = $this->prepareTestRoot($testRootReady);
41 2
        $di = Di::getDefault();
42 2
        include TEST_ROOT_PATH . '/vendor/phwoolcon/di.php';
43 2
        $this->di = $di;
44 2
        Clearer::clear();
45 2
        isset($assembler) && Config::get('database.default') && $assembler->runMigrations($this->di);
46 2
        $class = get_class($this);
47 2
        Log::debug("================== Running {$class}::{$this->getName()}() ... ==================");
48 2
        Timer::start();
49 2
    }
50
51 2
    public function tearDown()
52
    {
53 2
        $elapsed = Timer::stop();
54 2
        parent::tearDown();
55 2
        Log::debug("================== Finished, time elapsed: {$elapsed}. ==================");
56 2
    }
57
}
58