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

GacelaTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 10
c 4
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A test_get_cache_dir() 0 7 1
A test_exception_if_non_bootstrapped() 0 12 1
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