You are here

public function RoleFilterTest::testFilterExclusive in Search API 8

Tests preprocessing search items with an exclusive filter.

File

tests/src/Unit/Processor/RoleFilterTest.php, line 113

Class

RoleFilterTest
Tests the "Role filter" processor.

Namespace

Drupal\Tests\search_api\Unit\Processor

Code

public function testFilterExclusive() {
  $configuration['roles'] = [
    'editor',
  ];
  $configuration['default'] = 1;
  $this->processor
    ->setConfiguration($configuration);
  $this->processor
    ->alterIndexedItems($this->items);
  $this
    ->assertTrue(empty($this->items[Utility::createCombinedId('entity:user', '1:en')]), 'User with editor role was successfully removed.');
  $this
    ->assertTrue(!empty($this->items[Utility::createCombinedId('entity:user', '2:en')]), 'User without the editor role was not removed.');
  $this
    ->assertTrue(!empty($this->items[Utility::createCombinedId('entity:node', '1:en')]), 'Node item was not removed.');
}