|
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(); |
|
|
|
|
|
|
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
|
|
|
|