Skip to content

Commit

Permalink
Validate extension really is enabled in PHP
Browse files Browse the repository at this point in the history
  • Loading branch information
asgrim committed Dec 23, 2024
1 parent 5329ebe commit 8887791
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/behaviour/CliContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/** @psalm-api */
class CliContext implements Context
{
private const PHP_BINARY = 'php';
private string|null $output = null;
private int|null $exitCode = null;
/** @var list<string> */
Expand All @@ -37,7 +38,7 @@ public function iRunACommandToDownloadSpecificVersionOfAnExtension(string $versi
/** @param list<non-empty-string> $command */
public function runPieCommand(array $command): void
{
$pieCommand = array_merge(['php', ...$this->phpArguments, 'bin/pie'], $command, ['--skip-enable-extension']);
$pieCommand = array_merge([self::PHP_BINARY, ...$this->phpArguments, 'bin/pie'], $command);

$proc = (new Process($pieCommand))->mustRun();

Expand Down Expand Up @@ -123,13 +124,21 @@ public function theExtensionShouldHaveBeenInstalled(): void
{
$this->assertCommandSuccessful();

Assert::contains($this->output, 'Extension is enabled and loaded');

if (Platform::isWindows()) {
Assert::regex($this->output, '#Copied DLL to: [-\\\_:.a-zA-Z0-9]+\\\php_example_pie_extension.dll#');

return;
}

Assert::regex($this->output, '#Install complete: [-_a-zA-Z0-9/]+/example_pie_extension.so#');

$isExtEnabled = (new Process([self::PHP_BINARY, '-r', 'echo extension_loaded("example_pie_extension")?"yes":"no";']))
->mustRun()
->getOutput();

Assert::same('yes', $isExtEnabled);
}

#[Given('I have an invalid extension installed')]
Expand Down

0 comments on commit 8887791

Please sign in to comment.