You are here

public function AbstractProcessTest::testGetIncrementalOutput in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/process/Tests/AbstractProcessTest.php \Symfony\Component\Process\Tests\AbstractProcessTest::testGetIncrementalOutput()

File

vendor/symfony/process/Tests/AbstractProcessTest.php, line 378

Class

AbstractProcessTest
@author Robert Schönthal <seroscho@googlemail.com>

Namespace

Symfony\Component\Process\Tests

Code

public function testGetIncrementalOutput() {

  // use a lock file to toggle between writing ("W") and reading ("R") the
  // output stream
  $lock = tempnam(sys_get_temp_dir(), get_class($this) . 'Lock');
  file_put_contents($lock, 'W');
  $p = $this
    ->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 0; while ($n < 3) { if (\'W\' === file_get_contents(' . var_export($lock, true) . ')) { echo \' foo \'; $n++; file_put_contents(' . var_export($lock, true) . ', \'R\'); } usleep(100); }')));
  $p
    ->start();
  while ($p
    ->isRunning()) {
    if ('R' === file_get_contents($lock)) {
      $this
        ->assertLessThanOrEqual(1, preg_match_all('/foo/', $p
        ->getIncrementalOutput(), $matches));
      file_put_contents($lock, 'W');
    }
    usleep(100);
  }
  unlink($lock);
}