forked from sebastianbergmann/phpunit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
GH-1340: Process isolation blocks infinitely upon fatal error | ||
--FILE-- | ||
<?php | ||
|
||
$_SERVER['argv'][1] = '--no-configuration'; | ||
$_SERVER['argv'][3] = 'Issue1340Test'; | ||
$_SERVER['argv'][4] = dirname(__FILE__).'/1340/Issue1340Test.php'; | ||
|
||
require __DIR__ . '/../../bootstrap.php'; | ||
PHPUnit_TextUI_Command::main(); | ||
?> | ||
--EXPECTF-- | ||
PHPUnit %s by Sebastian Bergmann. | ||
|
||
. | ||
parent | ||
. | ||
child | ||
php://stdout | ||
. | ||
STDOUT | ||
....... | ||
|
||
Time: %s, Memory: %sMb | ||
|
||
OK (10 tests, 10 assertions) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
class Issue1340Test extends PHPUnit_Framework_TestCase | ||
{ | ||
protected function prepareTemplate(\Text_Template $template) { | ||
$property = new \ReflectionProperty($template, 'values'); | ||
$property->setAccessible(true); | ||
$value = $property->getValue($template); | ||
|
||
$template->setVar(array( | ||
'included_files' => $value['included_files'] . '$excessive_stdin = ' . var_export(str_repeat('1234567890', 30000), TRUE) . ";\n", | ||
)); | ||
} | ||
|
||
public function testSameProcess() | ||
{ | ||
echo "\nparent\n"; | ||
$this->assertTrue(TRUE); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testIsolatedDebugOutput() { | ||
echo "\nchild\n"; | ||
file_put_contents('php://stdout', "\nphp://stdout\n"); | ||
$this->assertTrue(TRUE); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testIsolatedDebugSTDOUT() { | ||
fwrite(STDOUT, "\nSTDOUT\n"); | ||
$this->assertTrue(TRUE); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedOutput expected | ||
* @see https://bugs.php.net/bug.php?id=43283 | ||
* @see https://gist.github.com/sun/d02c242514c8f34bccdb | ||
*/ | ||
public function testIsolatedExpectedOutput() { | ||
echo "\nexpected\n"; | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedOutput expected | ||
* @see https://bugs.php.net/bug.php?id=43283 | ||
* @see https://gist.github.com/sun/d02c242514c8f34bccdb | ||
*/ | ||
public function testIsolatedExpectedPhpSTDOUT() { | ||
file_put_contents('php://stdout', "\nexpected\n"); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedOutput STDOUT is a stream | ||
* @see https://bugs.php.net/bug.php?id=43283 | ||
* @see https://gist.github.com/sun/d02c242514c8f34bccdb | ||
*/ | ||
public function testIsolatedExpectedSTDOUT() { | ||
fwrite(STDOUT, "\nSTDOUT is a stream\n"); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedException \PHPUnit_Framework_Error | ||
* @expectedExceptionMessage php://stderr | ||
* @see https://bugs.php.net/bug.php?id=43283 | ||
* @see https://gist.github.com/sun/d02c242514c8f34bccdb | ||
*/ | ||
public function testIsolatedExpectedPhpSTDERR() { | ||
file_put_contents('php://stderr', "\nphp://stderr\n"); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedException \PHPUnit_Framework_Error | ||
* @expectedExceptionMessage STDERR | ||
* @see https://bugs.php.net/bug.php?id=43283 | ||
* @see https://gist.github.com/sun/d02c242514c8f34bccdb | ||
*/ | ||
public function testIsolatedExpectedSTDERR() { | ||
fwrite(STDERR, "\nSTDERR\n"); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedException \PHPUnit_Framework_Error_Notice | ||
* @expectedExceptionMessage Undefined variable: foo | ||
*/ | ||
public function testIsolatedNotice() { | ||
$bar = $foo['foo']; | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedException \PHPUnit_Framework_Error | ||
* @expectedExceptionMessage Fatal error: Call to undefined function undefined_function() | ||
*/ | ||
public function testIsolatedFatalError() { | ||
$undefined = 'undefined_function'; | ||
$undefined(); | ||
} | ||
} |