ProcessUtilsTest.php 1.4 KB

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