Skip to content

Commit

Permalink
Improve tests for INI-options via XML-configuration <php> element
Browse files Browse the repository at this point in the history
- ini_get() for 'foo' was not tested
- setting 'foo' didn't work because it isn't a PHP config setting
- add test for setting a valid PHP option with a scalar value
- add test for setting a valid PHP option referencing a constant
  • Loading branch information
Ewout Pieter den Ouden authored and sebastianbergmann committed May 31, 2018
1 parent 4e1f807 commit 61f123c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/Util/ConfigurationTest.php
Expand Up @@ -286,7 +286,7 @@ public function testPHPConfigurationIsReadCorrectly(): void
\dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . '.',
'/path/to/lib'
],
'ini' => ['foo' => ['value' => 'bar']],
'ini' => ['foo' => ['value' => 'bar'], 'highlight.keyword' => ['value' => '#123456'], 'highlight.string' => ['value' => 'TEST_CONFIG_INI_CONSTANT']],
'const' => ['FOO' => ['value' => false], 'BAR' => ['value' => true]],
'var' => ['foo' => ['value' => false]],
'env' => ['foo' => ['value' => true], 'bar' => ['value' => 'true', 'verbatim' => true], 'foo_force' => ['value' => 'forced', 'force' => true]],
Expand All @@ -306,10 +306,16 @@ public function testPHPConfigurationIsReadCorrectly(): void
*/
public function testPHPConfigurationIsHandledCorrectly(): void
{
\define('TEST_CONFIG_INI_CONSTANT', '#234567');
$savedIniHighlightKeyword = \ini_get('highlight.keyword');
$savedIniHighlightString = \ini_get('highlight.string');

$this->configuration->handlePHPConfiguration();

$path = \dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . '.' . PATH_SEPARATOR . '/path/to/lib';
$this->assertStringStartsWith($path, \ini_get('include_path'));
$this->assertEquals('#123456', \ini_get('highlight.keyword'));
$this->assertEquals(TEST_CONFIG_INI_CONSTANT, \ini_get('highlight.string'));
$this->assertFalse(\FOO);
$this->assertTrue(\BAR);
$this->assertFalse($GLOBALS['foo']);
Expand All @@ -321,6 +327,9 @@ public function testPHPConfigurationIsHandledCorrectly(): void
$this->assertEquals('bar', $_SERVER['foo']);
$this->assertEquals('bar', $_FILES['foo']);
$this->assertEquals('bar', $_REQUEST['foo']);

\ini_set('highlight.keyword', $savedIniHighlightKeyword);
\ini_set('highlight.string', $savedIniHighlightString);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions tests/_files/configuration.xml
Expand Up @@ -143,6 +143,8 @@
<includePath>.</includePath>
<includePath>/path/to/lib</includePath>
<ini name="foo" value="bar"/>
<ini name="highlight.keyword" value="#123456"/>
<ini name="highlight.string" value="TEST_CONFIG_INI_CONSTANT"/>
<const name="FOO" value="false"/>
<const name="BAR" value="true"/>
<var name="foo" value="false"/>
Expand Down
2 changes: 2 additions & 0 deletions tests/_files/configuration_xinclude.xml
Expand Up @@ -64,6 +64,8 @@
<includePath>.</includePath>
<includePath>/path/to/lib</includePath>
<ini name="foo" value="bar"/>
<ini name="highlight.keyword" value="#123456"/>
<ini name="highlight.string" value="TEST_CONFIG_INI_CONSTANT"/>
<const name="FOO" value="false"/>
<const name="BAR" value="true"/>
<var name="foo" value="false"/>
Expand Down

0 comments on commit 61f123c

Please sign in to comment.