public function CustomProviderRepositoryTest::testCustomProviderLoading in oEmbed Providers 1.1.x
Same name and namespace in other branches
- 2.x tests/src/Functional/CustomProviderRepositoryTest.php \Drupal\Tests\oembed_providers\Functional\CustomProviderRepositoryTest::testCustomProviderLoading()
- 1.0.x tests/src/Functional/CustomProviderRepositoryTest.php \Drupal\Tests\oembed_providers\Functional\CustomProviderRepositoryTest::testCustomProviderLoading()
Tests custom provider loading.
File
- tests/
src/ Functional/ CustomProviderRepositoryTest.php, line 46
Class
- CustomProviderRepositoryTest
- Tests custom provider loading.
Namespace
Drupal\Tests\oembed_providers\FunctionalCode
public function testCustomProviderLoading() {
/** @var \Drupal\oembed_providers\OEmbed\ProviderRepositoryDecorator $provider_repository */
$provider_repository = $this->container
->get('media.oembed.provider_repository');
// Verify custom providers are retrieved by getCustomProviders() method.
$custom_providers = $provider_repository
->getCustomProviders();
$provider_names = [];
foreach ($custom_providers as $custom_provider) {
$provider_names[] = $custom_provider['provider_name'];
}
$this
->assertTrue(in_array('UNL MediaHub', $provider_names), "UNL MediaHub is found as a custom provider");
$this
->assertTrue(in_array('Example Provider', $provider_names), "Example Provider is found as a custom provider");
$this
->assertFalse(in_array('Vimeo', $provider_names), "Vimeo is not found as a custom provider");
// Verify custom providers are retrieved by getAll() method.
$providers = $provider_repository
->getAll();
$provider_names = [];
foreach ($providers as $provider) {
$provider_names[] = $provider
->getName();
}
$this
->assertTrue(in_array('UNL MediaHub', $provider_names), "UNL MediaHub is found as a provider");
$this
->assertTrue(in_array('Example Provider', $provider_names), "Example Provider is found as a provider");
$this
->assertTrue(in_array('Vimeo', $provider_names), "Vimeo is found as a provider");
// Verify custom providers are retrieved by get() method.
$this
->assertNotEmpty($provider_repository
->get('UNL MediaHub'), "UNL MediaHub is found as a provider");
$this
->assertNotEmpty($provider_repository
->get('Example Provider'), "Example Provider is found as a provider");
$this
->assertNotEmpty($provider_repository
->get('Vimeo'), "Vimeo is found as a provider");
}