public function ProviderRepositoryTest::testNonExistingProviderDatabase in oEmbed Providers 2.x
Same name and namespace in other branches
- 1.0.x tests/src/Functional/ProviderRepositoryTest.php \Drupal\Tests\oembed_providers\Functional\ProviderRepositoryTest::testNonExistingProviderDatabase()
- 1.1.x tests/src/Functional/ProviderRepositoryTest.php \Drupal\Tests\oembed_providers\Functional\ProviderRepositoryTest::testNonExistingProviderDatabase()
Tests that provider discovery fails with a non-existent provider database.
@dataProvider providerNonExistingProviderDatabase
Parameters
string $providers_url: The URL of the provider database.
string $exception_message: The expected exception message.
File
- tests/
src/ Functional/ ProviderRepositoryTest.php, line 84
Class
- ProviderRepositoryTest
- Tests the oEmbed provider repository.
Namespace
Drupal\Tests\oembed_providers\FunctionalCode
public function testNonExistingProviderDatabase($providers_url, $exception_message) {
$this
->config('media.settings')
->set('oembed_providers_url', $providers_url)
->save();
// Set up a mock handler.
// Core test requires calls to external service.
$mock = new MockHandler([
new RequestException('Error Communicating with Server', new Request('GET', 'test')),
]);
$handlerStack = HandlerStack::create($mock);
$client = new Client([
'handler' => $handlerStack,
]);
$this->container
->set('http_client', $client);
$this
->expectException(ProviderException::class);
$this
->expectExceptionMessage($exception_message);
$this->container
->get('media.oembed.provider_repository')
->getAll();
}