|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Php\PieUnitTest\Platform\TargetPhp\Exception; |
| 6 | + |
| 7 | +use Php\Pie\Platform\TargetPhp\Exception\ExtensionPathProblem; |
| 8 | +use Php\Pie\Platform\TargetPhp\PhpBinaryPath; |
| 9 | +use PHPUnit\Framework\Attributes\CoversClass; |
| 10 | +use PHPUnit\Framework\TestCase; |
| 11 | + |
| 12 | +#[CoversClass(ExtensionPathProblem::class)] |
| 13 | +final class ExtensionPathProblemTest extends TestCase |
| 14 | +{ |
| 15 | + public function testExtensionPathNotSet(): void |
| 16 | + { |
| 17 | + $php = PhpBinaryPath::fromCurrentProcess(); |
| 18 | + |
| 19 | + self::assertSame( |
| 20 | + 'Could not determine extension path for ' . $php->phpBinaryPath . '; extension_dir => not set', |
| 21 | + ExtensionPathProblem::new($php, null)->getMessage(), |
| 22 | + ); |
| 23 | + } |
| 24 | + |
| 25 | + public function testExtensionPathDoesNotExist(): void |
| 26 | + { |
| 27 | + $php = PhpBinaryPath::fromCurrentProcess(); |
| 28 | + |
| 29 | + self::assertSame( |
| 30 | + 'Could not determine extension path for ' . $php->phpBinaryPath . '; extension_dir => /path/does/not/exist; does not exist', |
| 31 | + ExtensionPathProblem::new($php, '/path/does/not/exist')->getMessage(), |
| 32 | + ); |
| 33 | + } |
| 34 | + |
| 35 | + public function testExtensionPathIsAFile(): void |
| 36 | + { |
| 37 | + $php = PhpBinaryPath::fromCurrentProcess(); |
| 38 | + |
| 39 | + self::assertSame( |
| 40 | + 'Could not determine extension path for ' . $php->phpBinaryPath . '; extension_dir => ' . __FILE__ . '; exists, not a directory', |
| 41 | + ExtensionPathProblem::new($php, __FILE__)->getMessage(), |
| 42 | + ); |
| 43 | + } |
| 44 | + |
| 45 | + public function testExtensionPathIsADir(): void |
| 46 | + { |
| 47 | + $php = PhpBinaryPath::fromCurrentProcess(); |
| 48 | + |
| 49 | + self::assertSame( |
| 50 | + 'Could not determine extension path for ' . $php->phpBinaryPath . '; extension_dir => ' . __DIR__ . '; exists, is a directory', |
| 51 | + ExtensionPathProblem::new($php, __DIR__)->getMessage(), |
| 52 | + ); |
| 53 | + } |
| 54 | +} |
0 commit comments