-
-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Process] allow setting options esp. "create_new_console" to detach a…
… subprocess
- Loading branch information
1 parent
d158a45
commit a9bb93b
Showing
4 changed files
with
99 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Process\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Process\Process; | ||
|
||
/** | ||
* @author Andrei Olteanu <[email protected]> | ||
*/ | ||
class CreateNewConsoleTest extends TestCase | ||
{ | ||
public function testOptionCreateNewConsole() | ||
{ | ||
$this->expectNotToPerformAssertions(); | ||
try { | ||
$process = new Process(['php', __DIR__.'/ThreeSecondProcess.php']); | ||
$process->setOptions(['create_new_console' => true]); | ||
$process->disableOutput(); | ||
$process->start(); | ||
} catch (\Exception $e) { | ||
$this->fail($e); | ||
} | ||
} | ||
|
||
public function testItReturnsFastAfterStart() | ||
{ | ||
// The started process must run in background after the main has finished but that can't be tested with PHPUnit | ||
$startTime = microtime(true); | ||
$process = new Process(['php', __DIR__.'/ThreeSecondProcess.php']); | ||
$process->setOptions(['create_new_console' => true]); | ||
$process->disableOutput(); | ||
$process->start(); | ||
$this->assertLessThan(3000, $startTime - microtime(true)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
echo 'Worker started'; | ||
sleep(3); | ||
echo 'Worker done'; |