ProcessUtilsTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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\ProcessUtils;
  13. /**
  14. * @group legacy
  15. */
  16. class ProcessUtilsTest extends TestCase
  17. {
  18. /**
  19. * @dataProvider dataArguments
  20. */
  21. public function testEscapeArgument($result, $argument)
  22. {
  23. $this->assertSame($result, ProcessUtils::escapeArgument($argument));
  24. }
  25. public function dataArguments()
  26. {
  27. if ('\\' === \DIRECTORY_SEPARATOR) {
  28. return [
  29. ['"\"php\" \"-v\""', '"php" "-v"'],
  30. ['"foo bar"', 'foo bar'],
  31. ['^%"path"^%', '%path%'],
  32. ['"<|>\\" \\"\'f"', '<|>" "\'f'],
  33. ['""', ''],
  34. ['"with\trailingbs\\\\"', 'with\trailingbs\\'],
  35. ];
  36. }
  37. return [
  38. ["'\"php\" \"-v\"'", '"php" "-v"'],
  39. ["'foo bar'", 'foo bar'],
  40. ["'%path%'", '%path%'],
  41. ["'<|>\" \"'\\''f'", '<|>" "\'f'],
  42. ["''", ''],
  43. ["'with\\trailingbs\\'", 'with\trailingbs\\'],
  44. ["'withNonAsciiAccentLikeéÉèÈàÀöä'", 'withNonAsciiAccentLikeéÉèÈàÀöä'],
  45. ];
  46. }
  47. }