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

test_non_existing_service()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
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