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