1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace GacelaTest\Feature\Framework\StaticFacade; |
6
|
|
|
|
7
|
|
|
use Gacela\Framework\Gacela; |
8
|
|
|
use GacelaTest\Feature\Framework\StaticFacade\Module\Facade as TestStaticFacade; |
9
|
|
|
use GacelaTest\Feature\Framework\StaticFacade\Module\Factory as TestStaticFactory; |
10
|
|
|
use PHPUnit\Framework\TestCase; |
11
|
|
|
|
12
|
|
|
final class FeatureTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
public function setUp(): void |
15
|
|
|
{ |
16
|
|
|
Gacela::bootstrap(__DIR__); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
public function test_object_facade(): void |
20
|
|
|
{ |
21
|
|
|
$actual = (new TestStaticFacade())->formalGreet('Jesus'); |
22
|
|
|
|
23
|
|
|
self::assertSame('Hello, Jesus.', $actual); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function test_static_facade(): void |
27
|
|
|
{ |
28
|
|
|
$actual = TestStaticFacade::informalGreet('Chema'); |
29
|
|
|
|
30
|
|
|
self::assertSame('Hi, Chema!', $actual); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function test_static_facade_shares_factory(): void |
34
|
|
|
{ |
35
|
|
|
$f1 = TestStaticFacade::factory(); |
36
|
|
|
$f2 = TestStaticFacade::factory(); |
37
|
|
|
|
38
|
|
|
self::assertSame($f1, $f2); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function test_static_factory_from_facade(): void |
42
|
|
|
{ |
43
|
|
|
$actual = TestStaticFacade::factory() |
44
|
|
|
->getConfig() |
45
|
|
|
->getConfigValue(); |
46
|
|
|
|
47
|
|
|
self::assertSame('config-value', $actual); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function test_static_config_from_factory(): void |
51
|
|
|
{ |
52
|
|
|
$actual = TestStaticFactory::config() |
53
|
|
|
->getConfigValue(); |
54
|
|
|
|
55
|
|
|
self::assertSame('config-value', $actual); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|