1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace GacelaTest\Feature\Framework\BindingInterfacesInGacelaConfigFile; |
6
|
|
|
|
7
|
|
|
use Gacela\Framework\Bootstrap\GacelaConfig; |
8
|
|
|
use Gacela\Framework\Gacela; |
9
|
|
|
use GacelaTest\Feature\Framework\BindingInterfacesInGacelaConfigFile\Module\Domain\AbstractFromAnonymousClass; |
10
|
|
|
use GacelaTest\Feature\Framework\BindingInterfacesInGacelaConfigFile\Module\Domain\AbstractFromCallable; |
11
|
|
|
use GacelaTest\Feature\Framework\BindingInterfacesInGacelaConfigFile\Module\Domain\InterfaceFromAnonymousClass; |
12
|
|
|
use GacelaTest\Feature\Framework\BindingInterfacesInGacelaConfigFile\Module\Domain\InterfaceFromCallable; |
13
|
|
|
use PHPUnit\Framework\TestCase; |
14
|
|
|
|
15
|
|
|
final class FeatureTest extends TestCase |
16
|
|
|
{ |
17
|
|
|
private Module\Facade $facade; |
18
|
|
|
|
19
|
|
|
protected function setUp(): void |
20
|
|
|
{ |
21
|
|
|
Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void { |
22
|
|
|
$config->resetInMemoryCache(); |
23
|
|
|
}); |
24
|
|
|
|
25
|
|
|
$this->facade = new Module\Facade(); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function test_resolved_class(): void |
29
|
|
|
{ |
30
|
|
|
self::assertSame( |
31
|
|
|
[ |
32
|
|
|
'bool' => true, |
33
|
|
|
'string' => 'string', |
34
|
|
|
'int' => 1, |
35
|
|
|
'float' => 1.2, |
36
|
|
|
'array' => ['array'], |
37
|
|
|
], |
38
|
|
|
$this->facade->generateResolvedClass(), |
39
|
|
|
); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function test_mapping_abstract_from_anonymous_class(): void |
43
|
|
|
{ |
44
|
|
|
self::assertSame( |
45
|
|
|
AbstractFromAnonymousClass::class, |
46
|
|
|
$this->facade->generateResolveAbstractFromAnonymousClass(), |
47
|
|
|
); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function test_mapping_abstract_from_callable(): void |
51
|
|
|
{ |
52
|
|
|
self::assertSame( |
53
|
|
|
AbstractFromCallable::class, |
54
|
|
|
$this->facade->generateResolveAbstractFromCallable(), |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function test_mapping_interface_from_anonymous_class(): void |
59
|
|
|
{ |
60
|
|
|
self::assertSame( |
61
|
|
|
InterfaceFromAnonymousClass::class, |
62
|
|
|
$this->facade->generateResolveInterfaceFromAnonymousClass(), |
63
|
|
|
); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function test_mapping_interface_from_callable(): void |
67
|
|
|
{ |
68
|
|
|
self::assertSame( |
69
|
|
|
InterfaceFromCallable::class, |
70
|
|
|
$this->facade->generateResolveInterfaceFromCallable(), |
71
|
|
|
); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|