merged branch stloyd/bugfix/process_tests (PR #7947)

This PR was merged into the 2.1 branch.

Discussion
----------

[Process] Cleanup tests & prevent assertion that kills randomly Travis-CI

Commits
-------

05b987f [Process] Cleanup tests & prevent assertion that kills randomly Travis-CI
This commit is contained in:
Fabien Potencier 2013-05-06 12:36:22 +02:00
commit de98954016
6 changed files with 26 additions and 37 deletions

View File

@ -88,18 +88,21 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
*
* @dataProvider pipesCodeProvider
*/
public function testProcessPipes($expected, $code)
public function testProcessPipes($code, $size)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
$this->markTestSkipped('Test hangs on Windows & PHP due to https://bugs.php.net/bug.php?id=60120 and https://bugs.php.net/bug.php?id=51800');
}
$expected = str_repeat(str_repeat('*', 1024), $size) . '!';
$expectedLength = (1024 * $size) + 1;
$p = $this->getProcess(sprintf('php -r %s', escapeshellarg($code)));
$p->setStdin($expected);
$p->run();
$this->assertSame($expected, $p->getOutput());
$this->assertSame($expected, $p->getErrorOutput());
$this->assertEquals($expectedLength, strlen($p->getOutput()));
$this->assertEquals($expectedLength, strlen($p->getErrorOutput()));
}
public function chainedCommandsOutputProvider()
@ -338,13 +341,11 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase
'fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);',
'include \'' . __DIR__ . '/ProcessTestHelper.php\';',
);
$baseData = str_repeat('*', 1024);
$codes = array();
foreach (array(1, 16, 64, 1024, 4096) as $size) {
$data = str_repeat($baseData, $size) . '!';
foreach ($variations as $code) {
$codes[] = array($data, $code);
$codes[] = array($code, $size);
}
}

View File

@ -15,7 +15,6 @@ use Symfony\Component\Process\PhpProcess;
class PhpProcessTest extends \PHPUnit_Framework_TestCase
{
public function testNonBlockingWorks()
{
$expected = 'hello world!';

View File

@ -15,10 +15,7 @@ use Symfony\Component\Process\ProcessBuilder;
class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function shouldInheritEnvironmentVars()
public function testInheritEnvironmentVars()
{
$snapshot = $_ENV;
$_ENV = $expected = array('foo' => 'bar');
@ -32,10 +29,7 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
$_ENV = $snapshot;
}
/**
* @test
*/
public function shouldInheritAndOverrideEnvironmentVars()
public function testProcessShouldInheritAndOverrideEnvironmentVars()
{
$snapshot = $_ENV;
$_ENV = array('foo' => 'bar', 'bar' => 'baz');
@ -51,10 +45,7 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
$_ENV = $snapshot;
}
/**
* @test
*/
public function shouldInheritEnvironmentVarsByDefault()
public function testInheritEnvironmentVarsByDefault()
{
$pb = new ProcessBuilder();
$proc = $pb->add('foo')->getProcess();
@ -62,10 +53,7 @@ class ProcessBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertNull($proc->getEnv());
}
/**
* @test
*/
public function shouldNotReplaceExplicitlySetVars()
public function testNotReplaceExplicitlySetVars()
{
$snapshot = $_ENV;
$_ENV = array('foo' => 'bar');

View File

@ -37,7 +37,8 @@ class ProcessFailedExceptionTest extends \PHPUnit_Framework_TestCase
'\InvalidArgumentException',
'Expected a failed process, but the given process was successful.'
);
$exception = new ProcessFailedException($process);
new ProcessFailedException($process);
}
/**

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Process\Tests;
class SigchildDisabledProcessTest extends AbstractProcessTest
{
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testGetExitCode()
{
@ -22,7 +22,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testExitCodeCommandFailed()
{
@ -30,7 +30,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessIsSignaledIfStopped()
{
@ -38,7 +38,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessWithTermSignal()
{
@ -46,7 +46,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessIsNotSignaled()
{
@ -54,7 +54,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessWithoutTermSignal()
{
@ -62,7 +62,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testExitCodeText()
{
@ -73,7 +73,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testIsSuccessful()
{
@ -81,7 +81,7 @@ class SigchildDisabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testIsNotSuccessful()
{

View File

@ -14,7 +14,7 @@ namespace Symfony\Component\Process\Tests;
class SigchildEnabledProcessTest extends AbstractProcessTest
{
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessIsSignaledIfStopped()
{
@ -22,7 +22,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessWithTermSignal()
{
@ -30,7 +30,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessIsNotSignaled()
{
@ -38,7 +38,7 @@ class SigchildEnabledProcessTest extends AbstractProcessTest
}
/**
* @expectedException Symfony\Component\Process\Exception\RuntimeException
* @expectedException \Symfony\Component\Process\Exception\RuntimeException
*/
public function testProcessWithoutTermSignal()
{