public function LinksWidgetTest::testNoFilterResults in Facets 8
Tests widget without filters.
File
- tests/
src/ Unit/ Plugin/ widget/ LinksWidgetTest.php, line 37
Class
- LinksWidgetTest
- Unit test for widget.
Namespace
Drupal\Tests\facets\Unit\Plugin\widgetCode
public function testNoFilterResults() {
$facet = $this->facet;
$facet
->setResults($this->originalResults);
$this->widget
->setConfiguration([
'show_numbers' => TRUE,
]);
$output = $this->widget
->build($facet);
$this
->assertSame('array', gettype($output));
$this
->assertCount(4, $output['#items']);
$expected_links = [
$this
->buildLinkAssertion('Llama', 'llama', $facet, 10),
$this
->buildLinkAssertion('Badger', 'badger', $facet, 20),
$this
->buildLinkAssertion('Duck', 'duck', $facet, 15),
$this
->buildLinkAssertion('Alpaca', 'alpaca', $facet, 9),
];
foreach ($expected_links as $index => $value) {
$this
->assertSame('array', gettype($output['#items'][$index]));
$this
->assertEquals($value, $output['#items'][$index]['#title']);
$this
->assertSame('array', gettype($output['#items'][$index]['#title']));
$this
->assertEquals('link', $output['#items'][$index]['#type']);
$this
->assertEquals([
'facet-item',
], $output['#items'][$index]['#wrapper_attributes']['class']);
}
}