Skip to content

Commit

Permalink
Merge pull request #792 from whatthejeff/issue_789
Browse files Browse the repository at this point in the history
Fixes #789
  • Loading branch information
edorian committed Jan 26, 2013
2 parents 1c3e4c0 + 21f620f commit 72f9877
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions PHPUnit/Framework/Process/TestCaseMethod.tpl.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
{iniSettings}
ini_set('display_errors', 1);
set_include_path('{include_path}');
require 'PHPUnit/Autoload.php';
Expand Down
3 changes: 3 additions & 0 deletions PHPUnit/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -723,10 +723,12 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
$constants = PHPUnit_Util_GlobalState::getConstantsAsString();
$globals = PHPUnit_Util_GlobalState::getGlobalsAsString();
$includedFiles = PHPUnit_Util_GlobalState::getIncludedFilesAsString();
$iniSettings = PHPUnit_Util_GlobalState::getIniSettingsAsString();
} else {
$constants = '';
$globals = '';
$includedFiles = '';
$iniSettings = '';
}

if ($result->getCollectCodeCoverageInformation()) {
Expand Down Expand Up @@ -763,6 +765,7 @@ public function run(PHPUnit_Framework_TestResult $result = NULL)
'globals' => $globals,
'include_path' => $includePath,
'included_files' => $includedFiles,
'iniSettings' => $iniSettings,
'strict' => $strict
)
);
Expand Down
16 changes: 16 additions & 0 deletions PHPUnit/Util/GlobalState.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,22 @@ public static function getIncludedFilesAsString()
return $result;
}

public static function getIniSettingsAsString()
{
$result = '';
$iniSettings = ini_get_all(null, FALSE);

foreach ($iniSettings as $key => $value) {
$result .= sprintf(
'ini_set(%s, %s);' . "\n",
self::exportVariable($key),
self::exportVariable($value)
);
}

return $result;
}

public static function getConstantsAsString()
{
$constants = get_defined_constants(TRUE);
Expand Down
25 changes: 25 additions & 0 deletions Tests/TextUI/ini-isolation.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
phpunit --process-isolation -d default_mimetype=application/x-test IniTest ../_files/IniTest.php
--FILE--
<?php
define('PHPUNIT_TESTSUITE', TRUE);

$_SERVER['argv'][1] = '--no-configuration';
$_SERVER['argv'][2] = '--process-isolation';
$_SERVER['argv'][3] = '-d';
$_SERVER['argv'][4] = 'default_mimetype=application/x-test';
$_SERVER['argv'][5] = 'IniTest';
$_SERVER['argv'][6] = dirname(dirname(__FILE__)) . '/_files/IniTest.php';

require_once dirname(dirname(dirname(__FILE__))) . '/PHPUnit/Autoload.php';
PHPUnit_TextUI_Command::main();
?>
--EXPECTF--
PHPUnit %s by Sebastian Bergmann.

.

Time: %i %s, Memory: %sMb

OK (1 test, 1 assertion)

8 changes: 8 additions & 0 deletions Tests/_files/IniTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php
class IniTest extends PHPUnit_Framework_TestCase
{
public function testIni()
{
$this->assertEquals('application/x-test', ini_get('default_mimetype'));
}
}

0 comments on commit 72f9877

Please sign in to comment.