PhpProcessTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Process\PhpExecutableFinder;
  13. use Symfony\Component\Process\PhpProcess;
  14. class PhpProcessTest extends TestCase
  15. {
  16. public function testNonBlockingWorks()
  17. {
  18. $expected = 'hello world!';
  19. $process = new PhpProcess(<<<PHP
  20. <?php echo '$expected';
  21. PHP
  22. );
  23. $process->start();
  24. $process->wait();
  25. $this->assertEquals($expected, $process->getOutput());
  26. }
  27. public function testCommandLine()
  28. {
  29. $process = new PhpProcess(<<<'PHP'
  30. <?php echo 'foobar';
  31. PHP
  32. );
  33. $commandLine = $process->getCommandLine();
  34. $f = new PhpExecutableFinder();
  35. $this->assertContains($f->find(), $commandLine, '::getCommandLine() returns the command line of PHP before start');
  36. $process->start();
  37. $this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after start');
  38. $process->wait();
  39. $this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
  40. }
  41. }