You are here

public function ExcludeSpecifiedItemsProcessorTest::testMultiString in Facets 8

Tests filtering happens for string filter.

File

tests/src/Unit/Plugin/processor/ExcludeSpecifiedItemsProcessorTest.php, line 139

Class

ExcludeSpecifiedItemsProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\processor

Code

public function testMultiString() {
  $facet = new Facet([], 'facets_facet');
  $facet
    ->setResults($this->originalResults);
  $facet
    ->addProcessor([
    'processor_id' => 'exclude_specified_items',
    'weights' => [],
    'settings' => [
      'exclude' => 'alpaca',
      'regex' => 0,
    ],
  ]);
  $this->processor
    ->setConfiguration([
    'exclude' => 'llama,badger',
    'regex' => 0,
  ]);
  $filtered_results = $this->processor
    ->build($facet, $this->originalResults);
  $this
    ->assertCount(count($this->originalResults) - 2, $filtered_results);
  foreach ($filtered_results as $result) {
    $this
      ->assertNotEquals('llama', $result
      ->getDisplayValue());
    $this
      ->assertNotEquals('badger', $result
      ->getDisplayValue());
  }
}