Passed
Push — feature/add-config-files ( 1c4158...837ed6 )
by Jesús
05:48 queued 02:26
created

DocBlockResolverInMemoryAwareTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 43
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A test_existing_service_cached() 0 9 1
A test_non_existing_service() 0 6 1
A setUpBeforeClass() 0 3 1
A test_existing_service() 0 7 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Integration\Framework\DocBlockResolverAware;
6
7
use Gacela\Framework\Bootstrap\GacelaConfig;
8
use Gacela\Framework\ClassResolver\DocBlockService\CustomServicesCache;
9
use Gacela\Framework\ClassResolver\InMemoryCache;
10
use Gacela\Framework\Gacela;
11
use PHPUnit\Framework\TestCase;
12
13
final class DocBlockResolverInMemoryAwareTest extends TestCase
14
{
15
    public static function setUpBeforeClass(): void
16
    {
17
        InMemoryCache::resetCache();
18
    }
19
20
    protected function setUp(): void
21
    {
22
        Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void {
23
            $config->addAppConfig('config/in-memory/*.php');
24
        });
25
    }
26
27
    public function test_existing_service(): void
28
    {
29
        $dummy = new DummyDocBlockResolverAware();
30
        $actual = $dummy->getRepository()->findName();
31
32
        self::assertCount(1, InMemoryCache::getAll(CustomServicesCache::class));
33
        self::assertSame('name', $actual);
34
    }
35
36
    /**
37
     * @depends test_existing_service
38
     */
39
    public function test_existing_service_cached(): void
40
    {
41
        self::assertCount(1, InMemoryCache::getAll(CustomServicesCache::class));
42
43
        $dummy = new DummyDocBlockResolverAware();
44
        $dummy->getRepository()->findName();
45
        $dummy->getRepository()->findName();
46
47
        self::assertCount(1, InMemoryCache::getAll(CustomServicesCache::class));
48
    }
49
50
    public function test_non_existing_service(): void
51
    {
52
        $this->expectExceptionMessage('Missing the concrete return type for the method `getRepository()`');
53
54
        $dummy = new BadDummyDocBlockResolverAware();
55
        $dummy->getRepository();
56
    }
57
}
58