|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of PHP CS Fixer. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * Dariusz Rumiński <[email protected]> |
| 8 | + * |
| 9 | + * This source file is subject to the MIT license that is bundled |
| 10 | + * with this source code in the file LICENSE. |
| 11 | + */ |
| 12 | + |
| 13 | +namespace PhpCsFixer\Tests\Linter; |
| 14 | + |
| 15 | +use PhpCsFixer\Linter\ProcessLinterProcessBuilder; |
| 16 | +use PHPUnit\Framework\TestCase; |
| 17 | + |
| 18 | +/** |
| 19 | + * @author Dariusz Rumiński <[email protected]> |
| 20 | + * |
| 21 | + * @internal |
| 22 | + * |
| 23 | + * @covers \PhpCsFixer\Linter\ProcessLinterProcessBuilder |
| 24 | + */ |
| 25 | +final class ProcessLinterProcessBuilderTest extends TestCase |
| 26 | +{ |
| 27 | + /** |
| 28 | + * @param string $executable |
| 29 | + * @param string $file |
| 30 | + * @param string $expected |
| 31 | + * |
| 32 | + * @testWith ["php", "foo.php", "'php' '-l' 'foo.php'"] |
| 33 | + * ["C:\\Program Files\\php\\php.exe", "foo bar\\baz.php", "'C:\\Program Files\\php\\php.exe' '-l' 'foo bar\\baz.php'"] |
| 34 | + * @requires OS Linux|Darwin |
| 35 | + */ |
| 36 | + public function testPrepareCommandOnPhpOnLinuxOrMac($executable, $file, $expected) |
| 37 | + { |
| 38 | + $builder = new ProcessLinterProcessBuilder($executable); |
| 39 | + |
| 40 | + $this->assertSame( |
| 41 | + $expected, |
| 42 | + $builder->build($file)->getCommandLine() |
| 43 | + ); |
| 44 | + } |
| 45 | + |
| 46 | + /** |
| 47 | + * @param string $executable |
| 48 | + * @param string $file |
| 49 | + * @param string $expected |
| 50 | + * |
| 51 | + * @testWith ["php", "foo.php", "php -l foo.php"] |
| 52 | + * ["C:\\Program Files\\php\\php.exe", "foo bar\\baz.php", "\"C:\\Program Files\\php\\php.exe\" -l \"foo bar\\baz.php\""] |
| 53 | + * @requires OS ^Win |
| 54 | + */ |
| 55 | + public function testPrepareCommandOnPhpOnWindows($executable, $file, $expected) |
| 56 | + { |
| 57 | + $builder = new ProcessLinterProcessBuilder($executable); |
| 58 | + |
| 59 | + $this->assertSame( |
| 60 | + $expected, |
| 61 | + $builder->build($file)->getCommandLine() |
| 62 | + ); |
| 63 | + } |
| 64 | +} |
0 commit comments