TestCase::reloadConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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