PhpProcessTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Process\Tests;
  11. use Symfony\Component\Process\PhpExecutableFinder;
  12. use Symfony\Component\Process\PhpProcess;
  13. class PhpProcessTest extends \PHPUnit_Framework_TestCase
  14. {
  15. public function testNonBlockingWorks()
  16. {
  17. $expected = 'hello world!';
  18. $process = new PhpProcess(<<<PHP
  19. <?php echo '$expected';
  20. PHP
  21. );
  22. $process->start();
  23. $process->wait();
  24. $this->assertEquals($expected, $process->getOutput());
  25. }
  26. public function testCommandLine()
  27. {
  28. $process = new PhpProcess(<<<'PHP'
  29. <?php echo 'foobar';
  30. PHP
  31. );
  32. $commandLine = $process->getCommandLine();
  33. $f = new PhpExecutableFinder();
  34. $this->assertContains($f->find(), $commandLine, '::getCommandLine() returns the command line of PHP before start');
  35. $process->start();
  36. $this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after start');
  37. $process->wait();
  38. $this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
  39. }
  40. }