You are here

public function ExcludeSpecifiedItemsProcessorTest::testInvertMultiString in Facets 8

Tests filtering happens for string filter.

File

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

Class

ExcludeSpecifiedItemsProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\processor

Code

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