You are here

public function BooleanItemProcessorTest::testBuild in Facets 8

Tests filtering of results.

File

tests/src/Unit/Plugin/processor/BooleanItemProcessorTest.php, line 49

Class

BooleanItemProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\processor

Code

public function testBuild() {
  $facet = new Facet([], 'facets_facet');
  $facet
    ->setResults($this->originalResults);
  $filtered_results = $this->processor
    ->build($facet, $this->originalResults);

  // The default values for on / off are On and Off.
  $this
    ->assertEquals('Off', $filtered_results[0]
    ->getDisplayValue());
  $this
    ->assertEquals('On', $filtered_results[1]
    ->getDisplayValue());

  // Overwrite the on/off values.
  $configuration = [
    'on_value' => 'True',
    'off_value' => 'False',
  ];
  $this->processor
    ->setConfiguration($configuration);
  $filtered_results = $this->processor
    ->build($facet, $this->originalResults);
  $this
    ->assertEquals('False', $filtered_results[0]
    ->getDisplayValue());
  $this
    ->assertEquals('True', $filtered_results[1]
    ->getDisplayValue());
}