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

TestCase::prepareTestRoot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

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