function ProviderRepositoryTest::testRequestException
Same name in other branches
- 9 core/modules/media/tests/src/Unit/ProviderRepositoryTest.php \Drupal\Tests\media\Unit\ProviderRepositoryTest::testRequestException()
- 11.x core/modules/media/tests/src/Unit/ProviderRepositoryTest.php \Drupal\Tests\media\Unit\ProviderRepositoryTest::testRequestException()
Tests handling of exceptions when fetching the provider database.
File
-
core/
modules/ media/ tests/ src/ Unit/ ProviderRepositoryTest.php, line 181
Class
- ProviderRepositoryTest
- @coversDefaultClass \Drupal\media\OEmbed\ProviderRepository
Namespace
Drupal\Tests\media\UnitCode
public function testRequestException() : void {
$provider = $this->prophesize('\\Drupal\\media\\OEmbed\\Provider')
->reveal();
// This data is expired (stale), but it should be returned anyway.
$this->keyValue
->set('oembed_providers', [
'data' => [
'YouTube' => $provider,
],
'expires' => $this->currentTime - 86400,
]);
$response = new Response(503);
$this->responses
->append($response, $response);
$this->assertSame($provider, $this->repository
->get('YouTube'));
// When there is no stored data, we should get an exception.
$this->keyValue
->delete('oembed_providers');
$this->expectException(ProviderException::class);
$this->repository
->get('YouTube');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.