ProcessLinterProcessBuilderTest.php 1.8 KB

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