function ProviderRepositoryTest::testEmptyProviderList

Same name and namespace in other branches
  1. 10 core/modules/media/tests/src/Kernel/ProviderRepositoryTest.php \Drupal\Tests\media\Kernel\ProviderRepositoryTest::testEmptyProviderList()
  2. 11.x core/modules/media/tests/src/Kernel/ProviderRepositoryTest.php \Drupal\Tests\media\Kernel\ProviderRepositoryTest::testEmptyProviderList()
  3. 8.9.x core/modules/media/tests/src/Functional/ProviderRepositoryTest.php \Drupal\Tests\media\Functional\ProviderRepositoryTest::testEmptyProviderList()
  4. main core/modules/media/tests/src/Kernel/ProviderRepositoryTest.php \Drupal\Tests\media\Kernel\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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.