function ResourceFetcherTest::testFetchTimeout
Same name in other branches
- 9 core/modules/media/tests/src/Unit/ResourceFetcherTest.php \Drupal\Tests\media\Unit\ResourceFetcherTest::testFetchTimeout()
- 11.x core/modules/media/tests/src/Unit/ResourceFetcherTest.php \Drupal\Tests\media\Unit\ResourceFetcherTest::testFetchTimeout()
Tests that resources are fetched with a hard-coded timeout.
File
-
core/
modules/ media/ tests/ src/ Unit/ ResourceFetcherTest.php, line 28
Class
- ResourceFetcherTest
- @group media
Namespace
Drupal\Tests\media\UnitCode
public function testFetchTimeout() : void {
$url = 'https://example.com/oembed?url=resource';
$headers = [
'Content-Type' => [
'text/javascript',
],
];
$body = Json::encode([
'version' => '1.0',
'type' => 'video',
'html' => 'test',
]);
$response = new Response(200, $headers, $body);
$client = $this->prophesize(Client::class);
$client->request('GET', $url, [
RequestOptions::TIMEOUT => 5,
])
->shouldBeCalled()
->willReturn($response);
$fetcher = new ResourceFetcher($client->reveal(), $this->createMock('\\Drupal\\media\\OEmbed\\ProviderRepositoryInterface'), new NullBackend('default'));
$fetcher->fetchResource($url);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.