1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace PhelTest\Unit\Compiler\Config; |
6
|
|
|
|
7
|
|
|
use Phel\Config\PhelBuildConfig; |
8
|
|
|
use PHPUnit\Framework\TestCase; |
9
|
|
|
|
10
|
|
|
final class PhelBuildConfigTest extends TestCase |
11
|
|
|
{ |
12
|
|
|
public function test_default(): void |
13
|
|
|
{ |
14
|
|
|
$config = (new PhelBuildConfig()); |
15
|
|
|
|
16
|
|
|
$expected = [ |
17
|
|
|
PhelBuildConfig::MAIN_PHEL_NAMESPACE => '', |
18
|
|
|
PhelBuildConfig::DEST_DIR => 'out', |
19
|
|
|
PhelBuildConfig::MAIN_PHP_FILENAME => 'index.php', |
20
|
|
|
PhelBuildConfig::MAIN_PHP_PATH => 'out/index.php', |
21
|
|
|
]; |
22
|
|
|
|
23
|
|
|
self::assertSame($expected, $config->jsonSerialize()); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function test_defined_phel_ns(): void |
27
|
|
|
{ |
28
|
|
|
$config = (new PhelBuildConfig()) |
29
|
|
|
->setMainPhelNamespace('test-ns/boot'); |
30
|
|
|
|
31
|
|
|
$expected = [ |
32
|
|
|
PhelBuildConfig::MAIN_PHEL_NAMESPACE => 'test-ns/boot', |
33
|
|
|
PhelBuildConfig::DEST_DIR => 'out', |
34
|
|
|
PhelBuildConfig::MAIN_PHP_FILENAME => 'index.php', |
35
|
|
|
PhelBuildConfig::MAIN_PHP_PATH => 'out/index.php', |
36
|
|
|
]; |
37
|
|
|
|
38
|
|
|
self::assertSame($expected, $config->jsonSerialize()); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function test_dest_dir(): void |
42
|
|
|
{ |
43
|
|
|
$config = (new PhelBuildConfig()) |
44
|
|
|
->setDestDir('custom-out'); |
45
|
|
|
|
46
|
|
|
$expected = [ |
47
|
|
|
PhelBuildConfig::MAIN_PHEL_NAMESPACE => '', |
48
|
|
|
PhelBuildConfig::DEST_DIR => 'custom-out', |
49
|
|
|
PhelBuildConfig::MAIN_PHP_FILENAME => 'index.php', |
50
|
|
|
PhelBuildConfig::MAIN_PHP_PATH => 'custom-out/index.php', |
51
|
|
|
]; |
52
|
|
|
|
53
|
|
|
self::assertSame($expected, $config->jsonSerialize()); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function test_dest_dir_and_main_php_filename(): void |
57
|
|
|
{ |
58
|
|
|
$config = (new PhelBuildConfig()) |
|
|
|
|
59
|
|
|
->setDestDir('custom-out') |
60
|
|
|
->setMainPhpFilename('custom-index'); |
61
|
|
|
|
62
|
|
|
$expected = [ |
63
|
|
|
PhelBuildConfig::MAIN_PHEL_NAMESPACE => '', |
64
|
|
|
PhelBuildConfig::DEST_DIR => 'custom-out', |
65
|
|
|
PhelBuildConfig::MAIN_PHP_FILENAME => 'custom-index.php', |
66
|
|
|
PhelBuildConfig::MAIN_PHP_PATH => 'custom-out/custom-index.php', |
67
|
|
|
]; |
68
|
|
|
|
69
|
|
|
self::assertSame($expected, $config->jsonSerialize()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function test_main_php_path_over_php_filename(): void |
73
|
|
|
{ |
74
|
|
|
$config = (new PhelBuildConfig()) |
|
|
|
|
75
|
|
|
->setMainPhpPath('custom-out/custom-index.php') |
76
|
|
|
->setMainPhpFilename('other-name'); |
77
|
|
|
|
78
|
|
|
$expected = [ |
79
|
|
|
PhelBuildConfig::MAIN_PHEL_NAMESPACE => '', |
80
|
|
|
PhelBuildConfig::DEST_DIR => 'custom-out', |
81
|
|
|
PhelBuildConfig::MAIN_PHP_FILENAME => 'custom-index.php', |
82
|
|
|
PhelBuildConfig::MAIN_PHP_PATH => 'custom-out/custom-index.php', |
83
|
|
|
]; |
84
|
|
|
|
85
|
|
|
self::assertSame($expected, $config->jsonSerialize()); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function test_main_php_path(): void |
89
|
|
|
{ |
90
|
|
|
$config = (new PhelBuildConfig()) |
91
|
|
|
->setMainPhpPath('custom-out/custom-index.php'); |
92
|
|
|
|
93
|
|
|
$expected = [ |
94
|
|
|
PhelBuildConfig::MAIN_PHEL_NAMESPACE => '', |
95
|
|
|
PhelBuildConfig::DEST_DIR => 'custom-out', |
96
|
|
|
PhelBuildConfig::MAIN_PHP_FILENAME => 'custom-index.php', |
97
|
|
|
PhelBuildConfig::MAIN_PHP_PATH => 'custom-out/custom-index.php', |
98
|
|
|
]; |
99
|
|
|
|
100
|
|
|
self::assertSame($expected, $config->jsonSerialize()); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
public function test_main_php_path_without_ext(): void |
104
|
|
|
{ |
105
|
|
|
$config = (new PhelBuildConfig()) |
106
|
|
|
->setMainPhpPath('custom-out/custom-index'); |
107
|
|
|
|
108
|
|
|
$expected = [ |
109
|
|
|
PhelBuildConfig::MAIN_PHEL_NAMESPACE => '', |
110
|
|
|
PhelBuildConfig::DEST_DIR => 'custom-out', |
111
|
|
|
PhelBuildConfig::MAIN_PHP_FILENAME => 'custom-index.php', |
112
|
|
|
PhelBuildConfig::MAIN_PHP_PATH => 'custom-out/custom-index.php', |
113
|
|
|
]; |
114
|
|
|
|
115
|
|
|
self::assertSame($expected, $config->jsonSerialize()); |
116
|
|
|
} |
117
|
|
|
} |
118
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.