CreateNewConsoleTest.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Process;
  13. /**
  14. * @author Andrei Olteanu <andrei@flashsoft.eu>
  15. */
  16. class CreateNewConsoleTest extends TestCase
  17. {
  18. public function testOptionCreateNewConsole()
  19. {
  20. $this->expectNotToPerformAssertions();
  21. try {
  22. $process = new Process(['php', __DIR__.'/ThreeSecondProcess.php']);
  23. $process->setOptions(['create_new_console' => true]);
  24. $process->disableOutput();
  25. $process->start();
  26. } catch (\Exception $e) {
  27. $this->fail($e);
  28. }
  29. }
  30. public function testItReturnsFastAfterStart()
  31. {
  32. // The started process must run in background after the main has finished but that can't be tested with PHPUnit
  33. $startTime = microtime(true);
  34. $process = new Process(['php', __DIR__.'/ThreeSecondProcess.php']);
  35. $process->setOptions(['create_new_console' => true]);
  36. $process->disableOutput();
  37. $process->start();
  38. $this->assertLessThan(3000, $startTime - microtime(true));
  39. }
  40. }