|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace GacelaTest\Feature\Console\ValidateConfig; |
|
6
|
|
|
|
|
7
|
|
|
use Gacela\Console\Infrastructure\Command\ValidateConfigCommand; |
|
8
|
|
|
use Gacela\Framework\Bootstrap\GacelaConfig; |
|
9
|
|
|
use Gacela\Framework\Gacela; |
|
10
|
|
|
use PHPUnit\Framework\TestCase; |
|
11
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
|
12
|
|
|
|
|
13
|
|
|
final class ValidateConfigCommandTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
private CommandTester $command; |
|
16
|
|
|
|
|
17
|
|
|
protected function setUp(): void |
|
18
|
|
|
{ |
|
19
|
|
|
Gacela::bootstrap(__DIR__, static function (GacelaConfig $config): void { |
|
20
|
|
|
$config->resetInMemoryCache(); |
|
21
|
|
|
}); |
|
22
|
|
|
|
|
23
|
|
|
$this->command = new CommandTester(new ValidateConfigCommand()); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function test_validate_config_success(): void |
|
27
|
|
|
{ |
|
28
|
|
|
$this->command->execute([]); |
|
29
|
|
|
|
|
30
|
|
|
$output = $this->command->getDisplay(); |
|
31
|
|
|
|
|
32
|
|
|
self::assertStringContainsString('Validating Gacela Configuration', $output); |
|
33
|
|
|
self::assertStringContainsString('Checking bindings...', $output); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
public function test_validate_config_shows_warnings_if_no_gacela_php(): void |
|
37
|
|
|
{ |
|
38
|
|
|
$this->command->execute([]); |
|
39
|
|
|
|
|
40
|
|
|
$output = $this->command->getDisplay(); |
|
41
|
|
|
|
|
42
|
|
|
// This test directory doesn't have a gacela.php, so we should see a warning |
|
43
|
|
|
self::assertStringContainsString('Checking bindings...', $output); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function test_validate_config_exit_code_success(): void |
|
47
|
|
|
{ |
|
48
|
|
|
$exitCode = $this->command->execute([]); |
|
49
|
|
|
|
|
50
|
|
|
// Should be success even with warnings |
|
51
|
|
|
self::assertSame(0, $exitCode); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function test_validate_config_checks_circular_dependencies(): void |
|
55
|
|
|
{ |
|
56
|
|
|
$this->command->execute([]); |
|
57
|
|
|
|
|
58
|
|
|
$output = $this->command->getDisplay(); |
|
59
|
|
|
|
|
60
|
|
|
self::assertStringContainsString('Checking for circular dependencies...', $output); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function test_validate_config_checks_config_paths(): void |
|
64
|
|
|
{ |
|
65
|
|
|
$this->command->execute([]); |
|
66
|
|
|
|
|
67
|
|
|
$output = $this->command->getDisplay(); |
|
68
|
|
|
|
|
69
|
|
|
self::assertStringContainsString('Checking configuration paths...', $output); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|