mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-12 09:09:45 +01:00
42 lines
888 B
PHP
42 lines
888 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests\Shell;
|
|
|
|
use Psl\Shell;
|
|
use Psl\Tests\IOTestCase;
|
|
|
|
final class EscapeArgumentTest extends IOTestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
public function testEscapeArgument(string $argument): void
|
|
{
|
|
$output = Shell\execute(PHP_BINARY, ['-r', 'echo $argv[1];', $argument]);
|
|
|
|
static::assertSame($argument, $output);
|
|
}
|
|
|
|
/**
|
|
* @return iterable<array{0: string}>
|
|
*/
|
|
public function provideData(): iterable
|
|
{
|
|
yield ['a"b%c%'];
|
|
yield ['a"b^c^'];
|
|
yield ["a\nb'c"];
|
|
yield ['a^b c!'];
|
|
yield ["a!b\tc"];
|
|
yield ["look up ^"];
|
|
yield ['a\\\\"\\"'];
|
|
yield ['éÉèÈàÀöä'];
|
|
yield ['1'];
|
|
yield ['1.1'];
|
|
yield ['1%2'];
|
|
yield ["Hey there,\nHow are you doing!"];
|
|
yield [''];
|
|
}
|
|
}
|