public function HttpStreamWrapperTest::dataStat in Remote Stream Wrapper 8
File
- tests/
src/ Kernel/ HttpStreamWrapperTest.php, line 55
Class
- HttpStreamWrapperTest
- @coversDefaultClass \Drupal\remote_stream_wrapper\StreamWrapper\HttpStreamWrapper @group remote_stream_wrapper
Namespace
Drupal\Tests\remote_stream_wrapper\KernelCode
public function dataStat() {
$data = [];
// HTTP request sends a 405 Method Not Allowed on HEAD.
$data[] = [
'http://www.drupal.org/',
[
'size' => 50,
],
new ClientException(405, new Request('HEAD', ''), new Response(405)),
new Response(200, [
'Content-Length' => 50,
]),
];
// HTTP request sends an empty HEAD response.
$data[] = [
'http://www.drupal.org/test',
[
'size' => 50,
],
new Response(200),
new Response(200, [
'Content-Length' => 50,
]),
];
// HTTP request sends a valid HEAD response.
$data[] = [
'http://www.drupal.org/test.unknown',
[
'size' => 25,
],
new Response(200, [
'Content-Length' => 25,
]),
new Response(200, [
'Content-Length' => 50,
]),
];
// No Content-Type headers, rely on body size.
$data[] = [
'http://www.drupal.org/test.unknown',
[
'size' => 10,
],
new Response(200),
new Response(200, [], new Stream(fopen('php://temp', 'r'), [
'size' => 10,
])),
];
// Empty HEAD and GET responses.
$data[] = [
'https://www.drupal.org/',
[
'size' => 0,
],
new Response(200),
new Response(200),
];
// Both HEAD and GET are error responses.
$data[] = [
'https://www.drupal.org/',
NULL,
new ClientException(404, new Request('HEAD', ''), new Response(404)),
new ClientException(404, new Request('GET', ''), new Response(404)),
];
return $data;
}