ProcessUtilsTest.php 1.3 KB

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