Passed
Pull Request — main (#339)
by Chema
05:43 queued 01:20
created

DocBlockResolverAttributeAwareTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 4
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\Cache\CustomServicesPhpCache;
9
use Gacela\Framework\ClassResolver\Cache\InMemoryCache;
10
use Gacela\Framework\Gacela;
11
use GacelaTest\Feature\Util\DirectoryUtil;
12
use PHPUnit\Framework\Attributes\Depends;
13
use PHPUnit\Framework\TestCase;
14
15
final class DocBlockResolverAttributeAwareTest extends TestCase
16
{
17
    public static function setUpBeforeClass(): void
18
    {
19
        DirectoryUtil::removeDir(__DIR__ . DIRECTORY_SEPARATOR . '.gacela');
20
    }
21
22
    protected function setUp(): void
23
    {
24
        Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void {
25
            $config->resetInMemoryCache();
26
        });
27
    }
28
29
    public function test_existing_service(): void
30
    {
31
        $dummy = new DummyAttributeDocBlockResolverAware();
32
        $actual = $dummy->getRepository()->findName();
0 ignored issues
show
Bug introduced by
The method getRepository() does not exist on GacelaTest\Integration\F...teDocBlockResolverAware. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

32
        $actual = $dummy->/** @scrutinizer ignore-call */ getRepository()->findName();
Loading history...
33
34
        self::assertCount(1, InMemoryCache::getAllFromKey(CustomServicesPhpCache::class));
35
        self::assertSame('name', $actual);
36
    }
37
38
    #[Depends('test_existing_service')]
39
    public function test_existing_service_cached(): void
40
    {
41
        self::assertCount(0, InMemoryCache::getAllFromKey(CustomServicesPhpCache::class));
42
43
        $dummy = new DummyAttributeDocBlockResolverAware();
44
        $dummy->getRepository()->findName();
45
        $dummy->getRepository()->findName();
46
47
        self::assertCount(1, InMemoryCache::getAllFromKey(CustomServicesPhpCache::class));
48
    }
49
}
50