You are here

public function RenderedItemTest::testAlterPropertyDefinitions in Search API 8

Tests whether the property is correctly added by the processor.

File

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

Class

RenderedItemTest
Tests the "Rendered item" processor.

Namespace

Drupal\Tests\search_api\Kernel\Processor

Code

public function testAlterPropertyDefinitions() {

  // Check for added properties when no datasource is given.
  $properties = $this->processor
    ->getPropertyDefinitions(NULL);
  $this
    ->assertArrayHasKey('rendered_item', $properties, 'The Properties where modified with the "rendered_item".');
  $this
    ->assertInstanceOf('Drupal\\search_api\\Plugin\\search_api\\processor\\Property\\RenderedItemProperty', $properties['rendered_item'], 'Added property has the correct class.');
  $this
    ->assertInstanceOf(DataDefinitionInterface::class, $properties['rendered_item'], 'The "rendered_item" contains a valid DataDefinition instance.');
  $this
    ->assertEquals('search_api_html', $properties['rendered_item']
    ->getDataType(), 'Correct DataType set in the DataDefinition.');

  // Verify that there are no properties if a datasource is given.
  $properties = $this->processor
    ->getPropertyDefinitions($this->index
    ->getDatasource('entity:node'));
  $this
    ->assertEquals([], $properties, '"render_item" property not added when datasource is given.');
}