|
57 | 57 | final class PhpBinaryPathTest extends TestCase |
58 | 58 | { |
59 | 59 | private const FAKE_PHP_EXECUTABLE = __DIR__ . '/../../../assets/fake-php.sh'; |
| 60 | + private const PHP_INVALID_VERSION = __DIR__ . '/../../../assets/fake-php-invalid-version.sh'; |
60 | 61 | private const VALID_PHP_WITH_WARNINGS = __DIR__ . '/../../../assets/valid-php-with-warnings.sh'; |
61 | 62 |
|
62 | 63 | public function testNonExistentPhpBinaryIsRejected(): void |
@@ -85,13 +86,22 @@ public function testNonExecutablePhpBinaryIsRejected(): void |
85 | 86 | PhpBinaryPath::fromPhpBinaryPath(__FILE__); |
86 | 87 | } |
87 | 88 |
|
| 89 | + #[RequiresOperatingSystemFamily('Linux')] |
88 | 90 | public function testInvalidPhpBinaryIsRejected(): void |
89 | 91 | { |
90 | 92 | $this->expectException(InvalidPhpBinaryPath::class); |
91 | 93 | $this->expectExceptionMessage('does not appear to be a PHP binary'); |
92 | 94 | PhpBinaryPath::fromPhpBinaryPath(self::FAKE_PHP_EXECUTABLE); |
93 | 95 | } |
94 | 96 |
|
| 97 | + #[RequiresOperatingSystemFamily('Linux')] |
| 98 | + public function testInvalidVersion(): void |
| 99 | + { |
| 100 | + $phpBinary = PhpBinaryPath::fromPhpBinaryPath(self::PHP_INVALID_VERSION); |
| 101 | + self::assertSame('5.6.40', $phpBinary->version()); |
| 102 | + self::assertSame('5.6', $phpBinary->majorMinorVersion()); |
| 103 | + } |
| 104 | + |
95 | 105 | public function testWarningsAndDeprecationsAreFiltered(): void |
96 | 106 | { |
97 | 107 | if (Platform::isWindows()) { |
@@ -129,11 +139,17 @@ public static function phpConfigPathProvider(): array |
129 | 139 |
|
130 | 140 | $possiblePhpConfigPaths = array_filter( |
131 | 141 | [ |
| 142 | + ['/usr/bin/php-config8.5', '8.5'], |
| 143 | + ['/usr/bin/php-config8.4', '8.4'], |
132 | 144 | ['/usr/bin/php-config8.3', '8.3'], |
133 | 145 | ['/usr/bin/php-config8.2', '8.2'], |
134 | 146 | ['/usr/bin/php-config8.1', '8.1'], |
135 | 147 | ['/usr/bin/php-config8.0', '8.0'], |
136 | 148 | ['/usr/bin/php-config7.4', '7.4'], |
| 149 | + ['/usr/bin/php-config7.3', '7.3'], |
| 150 | + ['/usr/bin/php-config7.2', '7.2'], |
| 151 | + ['/usr/bin/php-config7.1', '7.1'], |
| 152 | + ['/usr/bin/php-config5.6', '5.6'], |
137 | 153 | ], |
138 | 154 | static fn (array $phpConfigPath) => file_exists($phpConfigPath[0]) |
139 | 155 | && is_executable($phpConfigPath[0]), |
@@ -168,6 +184,11 @@ public function testFromPhpConfigExecutable(string $phpConfigPath, string $expec |
168 | 184 | $phpBinary->majorMinorVersion(), |
169 | 185 | ); |
170 | 186 |
|
| 187 | + self::assertStringStartsWith( |
| 188 | + $expectedMajorMinor . '.', |
| 189 | + $phpBinary->version(), |
| 190 | + ); |
| 191 | + |
171 | 192 | self::assertSame($phpConfigPath, $phpBinary->phpConfigPath()); |
172 | 193 | } |
173 | 194 |
|
|
0 commit comments