function MediaEmbedFilterTest::testBasics
Same name and namespace in other branches
- 9 core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTest::testBasics()
- 8.9.x core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTest::testBasics()
- 10 core/modules/media/tests/src/Kernel/MediaEmbedFilterTest.php \Drupal\Tests\media\Kernel\MediaEmbedFilterTest::testBasics()
Ensures media entities are rendered correctly.
@dataProvider providerTestBasics
File
-
core/
modules/ media/ tests/ src/ Kernel/ MediaEmbedFilterTest.php, line 32
Class
- MediaEmbedFilterTest
- @coversDefaultClass <a href="/api/drupal/core%21modules%21media%21src%21Plugin%21Filter%21MediaEmbed.php/class/MediaEmbed/11.x" title="Provides a filter to embed media items using a custom tag." class="local">\Drupal\media\Plugin\Filter\MediaEmbed</a> @group media
Namespace
Drupal\Tests\media\KernelCode
public function testBasics(array $embed_attributes, $expected_view_mode, array $expected_attributes, CacheableMetadata $expected_cacheability) : void {
$content = $this->createEmbedCode($embed_attributes);
$result = $this->applyFilter($content);
$this->assertCount(1, $this->cssSelect('div[data-media-embed-test-view-mode="' . $expected_view_mode . '"]'));
$this->assertHasAttributes($this->cssSelect('div[data-media-embed-test-view-mode="' . $expected_view_mode . '"]')[0], $expected_attributes);
$this->assertEqualsCanonicalizing($expected_cacheability->getCacheTags(), $result->getCacheTags());
$this->assertEqualsCanonicalizing($expected_cacheability->getCacheContexts(), $result->getCacheContexts());
$this->assertSame($expected_cacheability->getCacheMaxAge(), $result->getCacheMaxAge());
$this->assertSame([
'library',
], array_keys($result->getAttachments()));
$this->assertSame([
'media/filter.caption',
], $result->getAttachments()['library']);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.