You are here

public function ProviderRepositoryTest::testEmptyProviderList in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Functional/ProviderRepositoryTest.php \Drupal\Tests\media\Functional\ProviderRepositoryTest::testEmptyProviderList()

Tests that provider discovery fails if the provider database is empty.

@dataProvider providerEmptyProviderList

Parameters

string $content: The expected JSON content of the provider database.

File

core/modules/media/tests/src/Functional/ProviderRepositoryTest.php, line 30

Class

ProviderRepositoryTest
Tests the oEmbed provider repository.

Namespace

Drupal\Tests\media\Functional

Code

public function testEmptyProviderList($content) {
  $response = $this
    ->prophesize('\\GuzzleHttp\\Psr7\\Response');
  $response
    ->getBody()
    ->willReturn(Utils::streamFor($content));
  $client = $this
    ->createMock('\\GuzzleHttp\\Client');
  $client
    ->method('request')
    ->withAnyParameters()
    ->willReturn($response
    ->reveal());
  $this->container
    ->set('http_client', $client);
  $this
    ->expectException(ProviderException::class);
  $this
    ->expectExceptionMessage('Remote oEmbed providers database returned invalid or empty list.');
  $this->container
    ->get('media.oembed.provider_repository')
    ->getAll();
}