public function AbstractProcessTest::testAllOutputIsActuallyReadOnTermination in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/process/Tests/AbstractProcessTest.php \Symfony\Component\Process\Tests\AbstractProcessTest::testAllOutputIsActuallyReadOnTermination()
File
- vendor/
symfony/ process/ Tests/ AbstractProcessTest.php, line 95
Class
- AbstractProcessTest
- @author Robert Schönthal <seroscho@googlemail.com>
Namespace
Symfony\Component\Process\TestsCode
public function testAllOutputIsActuallyReadOnTermination() {
// this code will result in a maximum of 2 reads of 8192 bytes by calling
// start() and isRunning(). by the time getOutput() is called the process
// has terminated so the internal pipes array is already empty. normally
// the call to start() will not read any data as the process will not have
// generated output, but this is non-deterministic so we must count it as
// a possibility. therefore we need 2 * PipesInterface::CHUNK_SIZE plus
// another byte which will never be read.
$expectedOutputSize = PipesInterface::CHUNK_SIZE * 2 + 2;
$code = sprintf('echo str_repeat(\'*\', %d);', $expectedOutputSize);
$p = $this
->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg($code)));
$p
->start();
// Let's wait enough time for process to finish...
// Here we don't call Process::run or Process::wait to avoid any read of pipes
usleep(500000);
if ($p
->isRunning()) {
$this
->markTestSkipped('Process execution did not complete in the required time frame');
}
$o = $p
->getOutput();
$this
->assertEquals($expectedOutputSize, strlen($o));
}