You are here

public function DependentFacetProcessorTest::testNotEmpty in Facets 8

Tests that facet is not empty.

@dataProvider provideNegated

File

tests/src/Unit/Plugin/processor/DependentFacetProcessorTest.php, line 79

Class

DependentFacetProcessorTest
Unit test for processor.

Namespace

Drupal\Tests\facets\Unit\Plugin\processor

Code

public function testNotEmpty($negated) {
  $facet = new Facet([
    'id' => 'owl',
    'name' => 'øwl',
  ], 'facets_facet');
  $facet
    ->setActiveItem('snow_owl');
  $facetManager = $this
    ->prophesize(DefaultFacetManager::class);
  $facetManager
    ->returnProcessedFacet($facet)
    ->willReturn($facet);
  $entityStorage = $this
    ->prophesize(EntityStorageInterface::class);
  $entityStorage
    ->load('owl')
    ->willReturn($facet);
  $etm = $this
    ->prophesize(EntityTypeManagerInterface::class);
  $etm
    ->getStorage('facets_facet')
    ->willReturn($entityStorage
    ->reveal());
  $configuration = [
    'owl' => [
      'enable' => TRUE,
      'negate' => $negated,
      'condition' => 'not_empty',
    ],
  ];
  $dfp = new DependentFacetProcessor($configuration, 'dependent_facet_processor', [], $facetManager
    ->reveal(), $etm
    ->reveal());
  $computed = $dfp
    ->build($facet, $this->results);
  if ($negated) {
    $this
      ->assertEquals($computed, []);
  }
  else {
    $this
      ->assertEquals($computed, $this->results);
  }
}