菜谱项目

PhpProcessTest.php 1.3KB

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 PHPUnit\Framework\TestCase;
  12. use Symfony\Component\Process\PhpProcess;
  13. class PhpProcessTest extends 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 phpversion().PHP_SAPI;
  30. PHP
  31. );
  32. $commandLine = $process->getCommandLine();
  33. $process->start();
  34. $this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after start');
  35. $process->wait();
  36. $this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
  37. $this->assertSame(PHP_VERSION.PHP_SAPI, $process->getOutput());
  38. }
  39. }