Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix php ini parsing from the CLI #63

Merged
merged 6 commits into from Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Runtime.php
Expand Up @@ -289,8 +289,12 @@ public function getCurrentSettings(array $values): array
foreach ($values as $value) {
$set = ini_get($value);

if (isset($config[$value]) && $set != $config[$value]) {
sebastianbergmann marked this conversation as resolved.
Show resolved Hide resolved
$diff[] = sprintf('%s=%s', $value, $set);
if ($set == null) {
sebastianbergmann marked this conversation as resolved.
Show resolved Hide resolved
continue;
}

if ((!isset($config[$value]) || ($set != $config[$value]))) {
sebastianbergmann marked this conversation as resolved.
Show resolved Hide resolved
$diff[$value] = sprintf('%s=%s', $value, $set);
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions tests/RuntimeTest.php
Expand Up @@ -142,6 +142,30 @@ public function testGetVendorUrlReturnsPhpDotNetWhenRunningPhp(): void
$this->assertSame('https://secure.php.net/', $this->env->getVendorUrl());
}

public function testDiscardingCommentsReturnsFalseIfOpcacheIsNotActive(): void
sebastianbergmann marked this conversation as resolved.
Show resolved Hide resolved
{
$this->assertFalse((new Runtime)->discardsComments());
}

public function testGetCurrentSettingsReturnsEmptyDiffIfNoValuesArePassed()
{
$this->assertSame([], (new Runtime)->getCurrentSettings([]));
}

/**
* @requires extension xdebug
*/
public function testGetCurrentSettingsReturnsCorrectDiffIfXdebugValuesArePassed()
{
$this->assertIsArray((new Runtime)->getCurrentSettings(['xdebug.mode']));
$this->assertArrayHasKey('xdebug.mode', (new Runtime)->getCurrentSettings(['xdebug.mode']));
}

public function testGetCurrentSettingsWillSkipSettingsThatIsNotSet()
{
$this->assertSame([], (new Runtime)->getCurrentSettings(['allow_url_include']));
}

private function markTestSkippedWhenNotRunningOnPhpdbg(): void
{
if ($this->isRunningOnPhpdbg()) {
Expand Down