Skip to content

Commit

Permalink
Merge pull request #1248 from Nikoms/issue1216
Browse files Browse the repository at this point in the history
Fix #1216 with unit test
  • Loading branch information
whatthejeff committed Jun 16, 2014
2 parents 168ac2b + e5014cb commit 91b7b16
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/TextUI/Command.php
Expand Up @@ -595,10 +595,6 @@ protected function handleArguments(array $argv)
);
}

if (isset($this->arguments['bootstrap'])) {
$this->handleBootstrap($this->arguments['bootstrap']);
}

if (isset($this->arguments['printer']) &&
is_string($this->arguments['printer'])) {
$this->arguments['printer'] = $this->handlePrinter($this->arguments['printer']);
Expand Down Expand Up @@ -647,7 +643,12 @@ protected function handleArguments(array $argv)

$configuration->handlePHPConfiguration();

if (!isset($this->arguments['bootstrap']) && isset($phpunit['bootstrap'])) {
/**
* Issue #1216
*/
if (isset($this->arguments['bootstrap'])) {
$this->handleBootstrap($this->arguments['bootstrap']);
}elseif (isset($phpunit['bootstrap'])) {
$this->handleBootstrap($phpunit['bootstrap']);
}

Expand Down Expand Up @@ -699,6 +700,13 @@ class_exists('PHPUnit_Extensions_SeleniumTestCase')) {
$this->arguments['test'] = $testSuite;
}
}
}else{
/**
* Issue #1216
*/
if (isset($this->arguments['bootstrap'])) {
$this->handleBootstrap($this->arguments['bootstrap']);
}
}

if (isset($this->arguments['test']) && is_string($this->arguments['test']) && substr($this->arguments['test'], -5, 5) == '.phpt') {
Expand Down
27 changes: 27 additions & 0 deletions tests/Regression/GitHub/1216.phpt
@@ -0,0 +1,27 @@
--TEST--
GH-1216: PHPUnit bootstrap must take globals vars even when the file is specified in command line
--FILE--
<?php

$_SERVER['argv'][1] = '--configuration';
$_SERVER['argv'][2] = dirname(__FILE__).'/1216/phpunit1216.xml';
$_SERVER['argv'][3] = '--debug';
$_SERVER['argv'][4] = '--bootstrap';
$_SERVER['argv'][5] = dirname(__FILE__).'/1216/bootstrap1216.php';
$_SERVER['argv'][6] = dirname(__FILE__) . '/1216/Issue1216Test.php';

require __DIR__ . '/../../bootstrap.php';
PHPUnit_TextUI_Command::main();
?>
--EXPECTF--
PHPUnit %s by Sebastian Bergmann.

Configuration read from %s


Starting test 'Issue1216Test::testConfigAvailableInBootstrap'.
.

Time: %s ms, Memory: %sMb

OK (1 test, 1 assertion)
8 changes: 8 additions & 0 deletions tests/Regression/GitHub/1216/Issue1216Test.php
@@ -0,0 +1,8 @@
<?php
class Issue1216Test extends PHPUnit_Framework_TestCase
{
public function testConfigAvailableInBootstrap()
{
$this->assertTrue($_ENV['configAvailableInBootstrap']);
}
}
2 changes: 2 additions & 0 deletions tests/Regression/GitHub/1216/bootstrap1216.php
@@ -0,0 +1,2 @@
<?php
$_ENV['configAvailableInBootstrap'] = isset($_ENV['loadedFromConfig']);
8 changes: 8 additions & 0 deletions tests/Regression/GitHub/1216/phpunit1216.xml
@@ -0,0 +1,8 @@
<phpunit>
<testsuite name="Github issue 1216">
<file>Issue1216Test.php</file>
</testsuite>
<php>
<env name="loadedFromConfig" value="1"/>
</php>
</phpunit>

0 comments on commit 91b7b16

Please sign in to comment.