You are here

public function ProviderRepositoryTest::testEmptyProviderList in oEmbed Providers 2.x

Same name and namespace in other branches
  1. 1.0.x tests/src/Functional/ProviderRepositoryTest.php \Drupal\Tests\oembed_providers\Functional\ProviderRepositoryTest::testEmptyProviderList()
  2. 1.1.x tests/src/Functional/ProviderRepositoryTest.php \Drupal\Tests\oembed_providers\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

tests/src/Functional/ProviderRepositoryTest.php, line 46

Class

ProviderRepositoryTest
Tests the oEmbed provider repository.

Namespace

Drupal\Tests\oembed_providers\Functional

Code

public function testEmptyProviderList($content) {
  $response = $this
    ->prophesize('\\GuzzleHttp\\Psr7\\Response');
  $response
    ->getBody()
    ->willReturn($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();
}