1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace GacelaTest\Unit\Framework\ClassResolver; |
6
|
|
|
|
7
|
|
|
use Gacela\Framework\ClassResolver\GlobalKey; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
|
10
|
|
|
final class GlobalKeyTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
public function test_empty_class_name(): void |
13
|
|
|
{ |
14
|
|
|
self::assertSame('\\', GlobalKey::fromClassName('')); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
public function test_only_class_name(): void |
18
|
|
|
{ |
19
|
|
|
self::assertSame('\ClassName', GlobalKey::fromClassName('ClassName')); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function test_using_the_module_prefix(): void |
23
|
|
|
{ |
24
|
|
|
self::assertSame( |
25
|
|
|
'\App\ModuleExample\Facade', |
26
|
|
|
GlobalKey::fromClassName('App\ModuleExample\ModuleFacade'), |
27
|
|
|
); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function test_starting_with_slash_and_using_module_prefix(): void |
31
|
|
|
{ |
32
|
|
|
self::assertSame( |
33
|
|
|
'\App\ModuleExample\Facade', |
34
|
|
|
GlobalKey::fromClassName('\App\ModuleExample\ModuleFacade'), |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function test_not_using_the_module_prefix_in_the_class(): void |
39
|
|
|
{ |
40
|
|
|
self::assertSame( |
41
|
|
|
'\App\ModuleExample\Facade', |
42
|
|
|
GlobalKey::fromClassName('App\ModuleExample\Facade'), |
43
|
|
|
); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function test_starting_with_slash_and_not_using_the_module_prefix_in_the_class(): void |
47
|
|
|
{ |
48
|
|
|
self::assertSame( |
49
|
|
|
'\App\ModuleExample\Facade', |
50
|
|
|
GlobalKey::fromClassName('\App\ModuleExample\Facade'), |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function test_dependency_provider_using_module_prefix(): void |
55
|
|
|
{ |
56
|
|
|
self::assertSame( |
57
|
|
|
'\App\ModuleExample\Provider', |
58
|
|
|
GlobalKey::fromClassName('\App\ModuleExample\ModuleProvider'), |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function test_dependency_provider_not_using_module_prefix(): void |
63
|
|
|
{ |
64
|
|
|
self::assertSame( |
65
|
|
|
'\App\ModuleExample\Provider', |
66
|
|
|
GlobalKey::fromClassName('\App\ModuleExample\Provider'), |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|