Passed
Push — bugfix/support-windows ( 0e99e7...b5ecf8 )
by Jesús
06:33 queued 02:55
created

GacelaTest::test_exception_if_non_bootstrapped()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Integration\Framework;
6
7
use Gacela\Framework\Bootstrap\GacelaConfig;
8
use Gacela\Framework\Exception\GacelaNotBootstrappedException;
9
use Gacela\Framework\Gacela;
10
use PHPUnit\Framework\TestCase;
11
use ReflectionClass;
12
13
final class GacelaTest extends TestCase
14
{
15
    public function test_exception_if_non_bootstrapped(): void
16
    {
17
        // Needed in order to set up the private `Gacela::$appRootDir as null` for this use case
18
        // when you try to access it before bootstrapping the application.
19
        $gacelaProxy = new ReflectionClass(Gacela::class);
20
        $appRootDirProp = $gacelaProxy->getProperty('appRootDir');
21
        $appRootDirProp->setAccessible(true);
22
        $appRootDirProp->setValue(null);
23
24
        $this->expectException(GacelaNotBootstrappedException::class);
25
26
        Gacela::rootDir();
27
    }
28
29
    public function test_get_cache_dir(): void
30
    {
31
        Gacela::bootstrap('any/root/directory', static function (GacelaConfig $config): void {
32
            $config->resetInMemoryCache();
33
        });
34
35
        self::assertEquals('any/root/directory', Gacela::rootDir());
36
    }
37
}
38