public function EntityEmbedFilterTest::providerFilterIntegration in Entity Embed 8
Data provider for testFilterIntegration().
File
- tests/
src/ Kernel/ EntityEmbedFilterTest.php, line 373
Class
- EntityEmbedFilterTest
- @coversDefaultClass \Drupal\entity_embed\Plugin\Filter\EntityEmbedFilter @group entity_embed
Namespace
Drupal\Tests\entity_embed\KernelCode
public function providerFilterIntegration() {
$default_asset_libraries = [
'entity_embed/caption',
];
$caption_additional_attributes = [
'data-caption' => 'Yo.',
];
$caption_verification_selector = 'figure > figcaption';
$caption_test_cases = [
'`data-caption`; only `entity_embed` ⇒ caption absent' => [
[
'entity_embed',
],
$caption_additional_attributes,
$caption_verification_selector,
FALSE,
$default_asset_libraries,
],
'`data-caption`; `filter_caption` + `entity_embed` ⇒ caption present' => [
[
'filter_caption',
'entity_embed',
],
$caption_additional_attributes,
$caption_verification_selector,
TRUE,
[
'filter/caption',
'entity_embed/caption',
],
],
'`<a>` + `data-caption`; `filter_caption` + `entity_embed` ⇒ caption present, link preserved' => [
[
'filter_caption',
'entity_embed',
],
$caption_additional_attributes,
'figure > a[href="https://www.drupal.org"] + figcaption',
TRUE,
[
'filter/caption',
'entity_embed/caption',
],
'<a href="https://www.drupal.org">',
'</a>',
],
];
$align_additional_attributes = [
'data-align' => 'center',
];
$align_verification_selector = 'div.embedded-entity.align-center';
$align_test_cases = [
'`data-align`; `entity_embed` ⇒ alignment absent' => [
[
'entity_embed',
],
$align_additional_attributes,
$align_verification_selector,
FALSE,
$default_asset_libraries,
],
'`data-align`; `filter_align` + `entity_embed` ⇒ alignment present' => [
[
'filter_align',
'entity_embed',
],
$align_additional_attributes,
$align_verification_selector,
TRUE,
$default_asset_libraries,
],
'`<a>` + `data-align`; `filter_align` + `entity_embed` ⇒ alignment present, link preserved' => [
[
'filter_align',
'entity_embed',
],
$align_additional_attributes,
'a[href="https://www.drupal.org"] > div.embedded-entity.align-center',
TRUE,
$default_asset_libraries,
'<a href="https://www.drupal.org">',
'</a>',
],
];
$caption_and_align_test_cases = [
'`data-caption` + `data-align`; `filter_align` + `filter_caption` + `entity_embed` ⇒ aligned caption present' => [
[
'filter_align',
'filter_caption',
'entity_embed',
],
$align_additional_attributes + $caption_additional_attributes,
'figure.align-center > figcaption',
TRUE,
[
'filter/caption',
'entity_embed/caption',
],
],
'`<a>` + `data-caption` + `data-align`; `filter_align` + `filter_caption` + `entity_embed` ⇒ aligned caption present, link preserved' => [
[
'filter_align',
'filter_caption',
'entity_embed',
],
$align_additional_attributes + $caption_additional_attributes,
'figure.align-center > a[href="https://www.drupal.org"] + figcaption',
TRUE,
[
'filter/caption',
'entity_embed/caption',
],
'<a href="https://www.drupal.org">',
'</a>',
],
];
return $caption_test_cases + $align_test_cases + $caption_and_align_test_cases;
}