public function SearchApiExcludeEntityProcessorTest::testAlterIndexedItems in Search API Exclude Entity 8
Tests altering the indexed items.
@covers ::alterIndexedItems
File
- tests/
src/ Unit/ Processor/ SearchApiExcludeEntityProcessorTest.php, line 160
Class
- SearchApiExcludeEntityProcessorTest
- Tests the "Search API Exclude Entity" processor.
Namespace
Drupal\Tests\search_api_exclude_entity\Unit\ProcessorCode
public function testAlterIndexedItems() {
$item1 = $this
->createMockItem('page', '1:en');
$item2 = $this
->createMockItem('article', '2:en', $this->excludeDisabledValue, $this->excludeDisabledValue);
$item3 = $this
->createMockItem('article', '3:en', $this->excludeDisabledValue, $this->excludeEnabledValue);
$item4 = $this
->createMockItem('article', '4:en', $this->excludeEnabledValue, $this->excludeEnabledValue);
$items = [
$item1
->getId() => $item1,
$item2
->getId() => $item2,
$item3
->getId() => $item3,
$item4
->getId() => $item4,
];
$this->processor
->alterIndexedItems($items);
$this
->assertArrayHasKey($item1
->getId(), $items, "Item without any exclude fields wasn't removed.");
$this
->assertArrayHasKey($item2
->getId(), $items, "Item with 0/2 of exclude fields enabled wasn't removed.");
$this
->assertArrayNotHasKey($item3
->getId(), $items, "Item with 1/2 of exclude fields enabled was removed.");
$this
->assertArrayNotHasKey($item4
->getId(), $items, "Item with 2/2 of exclude fields enabled was removed.");
}