You are here

public function RenderedItemTest::testDependencyRemoval in Search API 8

Tests whether the processor reacts correctly to removed dependencies.

File

tests/src/Kernel/Processor/RenderedItemTest.php, line 416

Class

RenderedItemTest
Tests the "Rendered item" processor.

Namespace

Drupal\Tests\search_api\Kernel\Processor

Code

public function testDependencyRemoval() {
  $expected = [
    'config' => [
      'core.entity_view_mode.comment.full',
      'core.entity_view_mode.node.full',
      'core.entity_view_mode.node.teaser',
      'core.entity_view_mode.user.compact',
    ],
  ];
  $this
    ->assertEquals($expected, $this->processor
    ->calculateDependencies());
  EntityViewMode::load('node.teaser')
    ->delete();
  $expected = [
    'entity:node' => [
      'page' => 'full',
    ],
    'entity:user' => [
      'user' => 'compact',
    ],
    'entity:comment' => [
      'comment' => 'full',
    ],
  ];

  // We need to reload the index.
  $index = Index::load($this->index
    ->id());
  $field_config = $index
    ->getField('rendered_item')
    ->getConfiguration();
  $this
    ->assertEquals($expected, $field_config['view_mode']);
}