public function ProviderRepositoryTest::testRequestException in Drupal 9
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');
}