You are here

public function EntityEmbedFilterTest::testFilterIntegration in Entity Embed 8

@covers \Drupal\filter\Plugin\Filter\FilterAlign @covers \Drupal\filter\Plugin\Filter\FilterCaption @dataProvider providerFilterIntegration

File

tests/src/Kernel/EntityEmbedFilterTest.php, line 337

Class

EntityEmbedFilterTest
@coversDefaultClass \Drupal\entity_embed\Plugin\Filter\EntityEmbedFilter @group entity_embed

Namespace

Drupal\Tests\entity_embed\Kernel

Code

public function testFilterIntegration(array $filter_ids, array $additional_attributes, $verification_selector, $expected_verification_success, array $expected_asset_libraries, $prefix = '', $suffix = '') {
  $content = $this
    ->createEmbedCode([
    'data-entity-type' => 'node',
    'data-entity-uuid' => static::EMBEDDED_ENTITY_UUID,
    'data-view-mode' => 'teaser',
  ] + $additional_attributes);
  $content = $prefix . $content . $suffix;
  $result = $this
    ->processText($content, 'en', $filter_ids);
  $this
    ->setRawContent($result
    ->getProcessedText());
  $this
    ->assertCount($expected_verification_success ? 1 : 0, $this
    ->cssSelect($verification_selector));
  $this
    ->assertHasAttributes($this
    ->cssSelect('div.embedded-entity')[0], [
    'data-entity-type' => 'node',
    'data-view-mode' => 'teaser',
    'data-entity-uuid' => static::EMBEDDED_ENTITY_UUID,
    'data-langcode' => 'en',
    'data-entity-embed-display' => 'entity_reference:entity_reference_entity_view',
    'data-entity-embed-display-settings' => 'teaser',
  ]);
  $this
    ->assertSame([
    'config:filter.format.plain_text',
    'foo:1',
    'node:1',
    'node_view',
    'user:2',
    'user_view',
  ], $result
    ->getCacheTags());
  $this
    ->assertSame([
    'timezone',
    'user.permissions',
  ], $result
    ->getCacheContexts());
  $this
    ->assertSame(Cache::PERMANENT, $result
    ->getCacheMaxAge());
  $this
    ->assertSame([
    'library',
  ], array_keys($result
    ->getAttachments()));
  $this
    ->assertSame($expected_asset_libraries, $result
    ->getAttachments()['library']);
}