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

test_existing_service()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 7
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\Gacela;
10
use PHPUnit\Framework\TestCase;
11
12
final class DocBlockResolverCustomServicesAwareTest extends TestCase
13
{
14
    public static function setUpBeforeClass(): void
15
    {
16
        CustomServicesCache::resetCache();
17
    }
18
19
    protected function setUp(): void
20
    {
21
        Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void {
22
            $config->addAppConfig('config/custom-services/*.php');
23
        });
24
    }
25
26
    public function test_existing_service(): void
27
    {
28
        $dummy = new DummyDocBlockResolverAware();
29
        $actual = $dummy->getRepository()->findName();
30
31
        self::assertCount(1, CustomServicesCache::getAll());
32
        self::assertSame('name', $actual);
33
    }
34
35
    /**
36
     * @depends test_existing_service
37
     */
38
    public function test_existing_service_cached(): void
39
    {
40
        self::assertCount(1, CustomServicesCache::getAll());
41
42
        $dummy = new DummyDocBlockResolverAware();
43
        $dummy->getRepository()->findName();
44
        $dummy->getRepository()->findName();
45
46
        self::assertCount(1, CustomServicesCache::getAll());
47
    }
48
49
    public function test_non_existing_service(): void
50
    {
51
        $this->expectExceptionMessage('Missing the concrete return type for the method `getRepository()`');
52
53
        $dummy = new BadDummyDocBlockResolverAware();
54
        $dummy->getRepository();
55
    }
56
}
57