protected function OEmbedTestTrait::hijackProviderEndpoints in Drupal 8
Same name and namespace in other branches
- 9 core/modules/media/tests/src/Traits/OEmbedTestTrait.php \Drupal\Tests\media\Traits\OEmbedTestTrait::hijackProviderEndpoints()
- 10 core/modules/media/tests/src/Traits/OEmbedTestTrait.php \Drupal\Tests\media\Traits\OEmbedTestTrait::hijackProviderEndpoints()
Ensures that all oEmbed provider endpoints defined in the fixture providers.json will use the media_test_oembed.resource.get route as their URL.
This requires the media_test_oembed module in order to work.
6 calls to OEmbedTestTrait::hijackProviderEndpoints()
- MediaSourceOEmbedVideoTest::testMediaOEmbedVideoSource in core/
modules/ media/ tests/ src/ FunctionalJavascript/ MediaSourceOEmbedVideoTest.php - Tests the oembed media source.
- MediaStandardProfileTest::setUp in core/
modules/ media/ tests/ src/ FunctionalJavascript/ MediaStandardProfileTest.php - OEmbedFormatterTest::testRender in core/
modules/ media/ tests/ src/ Functional/ FieldFormatter/ OEmbedFormatterTest.php - Tests the oEmbed field formatter.
- WidgetOEmbedTest::setUp in core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ WidgetOEmbedTest.php - WidgetOEmbedTest::testWidgetOEmbed in core/
modules/ media_library/ tests/ src/ FunctionalJavascript/ WidgetOEmbedTest.php - Tests that oEmbed media can be added in the Media library's widget.
File
- core/
modules/ media/ tests/ src/ Traits/ OEmbedTestTrait.php, line 67
Class
- OEmbedTestTrait
- Contains helper functions for testing oEmbed functionality in isolation.
Namespace
Drupal\Tests\media\TraitsCode
protected function hijackProviderEndpoints() {
$providers = $this
->getFixturesDirectory() . '/providers.json';
$providers = file_get_contents($providers);
$providers = Json::decode($providers);
$endpoint_url = Url::fromRoute('media_test_oembed.resource.get')
->setAbsolute()
->toString();
/** @var \Drupal\media_test_oembed\ProviderRepository $provider_repository */
$provider_repository = $this->container
->get('media.oembed.provider_repository');
foreach ($providers as &$provider) {
foreach ($provider['endpoints'] as &$endpoint) {
$endpoint['url'] = $endpoint_url;
}
$provider_repository
->setProvider(new Provider($provider['provider_name'], $provider['provider_url'], $provider['endpoints']));
}
}