Skip to content

[HttpKernel] Fix quotes expectations in tests #52473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public function testItGeneratesCurlCommandsAsExpected(array $request, string $ex
$collectedData = $sut->getClients();
self::assertCount(1, $collectedData['http_client']['traces']);
$curlCommand = $collectedData['http_client']['traces'][0]['curlCommand'];
self::assertEquals(sprintf($expectedCurlCommand, '\\' === \DIRECTORY_SEPARATOR ? '"' : "'"), $curlCommand);

$isWindows = '\\' === \DIRECTORY_SEPARATOR;
self::assertEquals(sprintf($expectedCurlCommand, $isWindows ? '"' : "'", $isWindows ? '' : "'"), $curlCommand);
}

public static function provideCurlRequests(): iterable
Expand Down Expand Up @@ -234,19 +236,19 @@ public static function provideCurlRequests(): iterable
'method' => 'POST',
'url' => 'http://localhost:8057/json',
'options' => [
'body' => 'foobarbaz',
'body' => 'foo bar baz',
],
],
'curl \\
--compressed \\
--request POST \\
--url %1$shttp://localhost:8057/json%1$s \\
--header %1$sAccept: */*%1$s \\
--header %1$sContent-Length: 9%1$s \\
--header %1$sContent-Length: 11%1$s \\
--header %1$sContent-Type: application/x-www-form-urlencoded%1$s \\
--header %1$sAccept-Encoding: gzip%1$s \\
--header %1$sUser-Agent: Symfony HttpClient (Native)%1$s \\
--data-raw %1$sfoobarbaz%1$s',
--data-raw %1$sfoo bar baz%1$s',
];
yield 'POST with array body' => [
[
Expand Down Expand Up @@ -284,7 +286,7 @@ public function __toString(): string
--header %1$sContent-Length: 211%1$s \\
--header %1$sAccept-Encoding: gzip%1$s \\
--header %1$sUser-Agent: Symfony HttpClient (Native)%1$s \\
--data-raw %1$sfoo=fooval%1$s --data-raw %1$sbar=barval%1$s --data-raw %1$sbaz=bazval%1$s --data-raw %1$sfoobar[baz]=bazval%1$s --data-raw %1$sfoobar[qux]=quxval%1$s --data-raw %1$sbazqux[0]=bazquxval1%1$s --data-raw %1$sbazqux[1]=bazquxval2%1$s --data-raw %1$sobject[fooprop]=foopropval%1$s --data-raw %1$sobject[barprop]=barpropval%1$s --data-raw %1$stostring=tostringval%1$s',
--data-raw %2$sfoo=fooval%2$s --data-raw %2$sbar=barval%2$s --data-raw %2$sbaz=bazval%2$s --data-raw %2$sfoobar[baz]=bazval%2$s --data-raw %2$sfoobar[qux]=quxval%2$s --data-raw %2$sbazqux[0]=bazquxval1%2$s --data-raw %2$sbazqux[1]=bazquxval2%2$s --data-raw %2$sobject[fooprop]=foopropval%2$s --data-raw %2$sobject[barprop]=barpropval%2$s --data-raw %2$stostring=tostringval%2$s',
];

// escapeshellarg on Windows replaces double quotes & percent signs with spaces
Expand Down