ProcessUtilsTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 array(
  29. array('"\"php\" \"-v\""', '"php" "-v"'),
  30. array('"foo bar"', 'foo bar'),
  31. array('^%"path"^%', '%path%'),
  32. array('"<|>\\" \\"\'f"', '<|>" "\'f'),
  33. array('""', ''),
  34. array('"with\trailingbs\\\\"', 'with\trailingbs\\'),
  35. );
  36. }
  37. return array(
  38. array("'\"php\" \"-v\"'", '"php" "-v"'),
  39. array("'foo bar'", 'foo bar'),
  40. array("'%path%'", '%path%'),
  41. array("'<|>\" \"'\\''f'", '<|>" "\'f'),
  42. array("''", ''),
  43. array("'with\\trailingbs\\'", 'with\trailingbs\\'),
  44. array("'withNonAsciiAccentLikeéÉèÈàÀöä'", 'withNonAsciiAccentLikeéÉèÈàÀöä'),
  45. );
  46. }
  47. }