You are here

public function ArrayWidgetTest::testNoFilterResults in Facets 8

Tests widget without filters.

File

tests/src/Unit/Plugin/widget/ArrayWidgetTest.php, line 27

Class

ArrayWidgetTest
Unit test for widget.

Namespace

Drupal\Tests\facets\Unit\Plugin\widget

Code

public function testNoFilterResults() {
  $facet = new Facet([], 'facets_facet');
  $facet
    ->setResults($this->originalResults);
  $facet
    ->setFieldIdentifier('tag');
  $output = $this->widget
    ->build($facet);
  $this
    ->assertSame('array', gettype($output));
  $this
    ->assertCount(4, $output['tag']);
  $expected_links = [
    [
      'url' => NULL,
      'values' => [
        'value' => 'Llama',
        'count' => 10,
      ],
    ],
    [
      'url' => NULL,
      'values' => [
        'value' => 'Badger',
        'count' => 20,
      ],
    ],
    [
      'url' => NULL,
      'values' => [
        'value' => 'Duck',
        'count' => 15,
      ],
    ],
    [
      'url' => NULL,
      'values' => [
        'value' => 'Alpaca',
        'count' => 9,
      ],
    ],
  ];
  foreach ($expected_links as $index => $value) {
    $this
      ->assertSame('array', gettype($output['tag'][$index]));
    $this
      ->assertEquals($value['values']['value'], $output['tag'][$index]['values']['value']);
    $this
      ->assertEquals($value['values']['count'], $output['tag'][$index]['values']['count']);
  }
}