Commit 6cbf1565 authored by borisson_'s avatar borisson_ Committed by StryKaizer

Issue #2855320 by borisson_, StryKaizer, jummonk, jeni_dc: Provide facet id...

Issue #2855320 by borisson_, StryKaizer, jummonk, jeni_dc: Provide facet id and raw value in Facets summary result items
parent 881e6d14
......@@ -46,6 +46,8 @@ function facets_theme($existing, $type, $theme, $path) {
'facets_result_item' => [
'base hook' => 'facets_result_item',
'variables' => [
'facet' => NULL,
'raw_value' => '',
'value' => '',
'show_count' => FALSE,
'count' => NULL,
......@@ -54,6 +56,7 @@ function facets_theme($existing, $type, $theme, $path) {
],
'facets_item_list' => [
'variables' => [
'facet' => NULL,
'items' => [],
'title' => '',
'list_type' => 'ul',
......
......@@ -110,7 +110,7 @@ class CoreNodeSearchDate extends QueryTypePluginBase {
$date_gap = $date_handler->getDateGap($active_item['start']['iso'], $active_item['end']['iso']);
$gap = $date_handler->getNextDateGap($date_gap, $date_handler::FACETS_DATE_MINUTE);
$last_parent = '[' . $active_item['start']['iso'] . ' TO ' . $active_item['end']['iso'] . ']';
$result = new Result($last_parent, $date_handler->formatTimestamp($active_item['start']['timestamp'], $date_gap), NULL);
$result = new Result($this->facet, $last_parent, $date_handler->formatTimestamp($active_item['start']['timestamp'], $date_gap), NULL);
$result->setActiveState(TRUE);
// Sets the children for the current parent..
if ($parent) {
......@@ -166,14 +166,14 @@ class CoreNodeSearchDate extends QueryTypePluginBase {
$last_value = end($facet_results);
if ($last_value) {
if ($new_value != $last_value->getRawValue()) {
$facet_results[] = new Result($new_value, $date_handler->formatTimestamp($value, $gap), $count);
$facet_results[] = new Result($this->facet, $new_value, $date_handler->formatTimestamp($value, $gap), $count);
}
else {
$last_value->setCount($last_value->getCount() + 1);
}
}
else {
$facet_results[] = new Result($new_value, $date_handler->formatTimestamp($value, $gap), $count);
$facet_results[] = new Result($this->facet, $new_value, $date_handler->formatTimestamp($value, $gap), $count);
}
}
......
......@@ -82,7 +82,7 @@ class CoreNodeSearchString extends QueryTypePluginBase {
if (!empty($results)) {
$facet_results = [];
foreach ($results as $result) {
$facet_results[] = new Result($result->value, $result->value, $result->count);
$facet_results[] = new Result($this->facet, $result->value, $result->value, $result->count);
}
$this->facet->setResults($facet_results);
}
......
......@@ -59,7 +59,7 @@ class SliderProcessor extends ProcessorPluginBase implements PostQueryProcessorI
$new_results = [];
for ($i = $min; $i <= $max; $i += $step) {
$count = isset($simple_results['f_' . $i]) ? $simple_results['f_' . $i]['count'] : 0;
$new_results[] = new Result((float) $i, (float) $i, $count);
$new_results[] = new Result($facet, (float) $i, (float) $i, $count);
}
// Overwrite the current facet values with the generated results.
......
......@@ -75,8 +75,8 @@ class RangeSliderProcessorTest extends UnitTestCase {
/** @var \Drupal\facets\Result\ResultInterface[] $results */
$results = [
new Result(1, 1, 1),
new Result(5, 5, 5),
new Result($facet->reveal(), 1, 1, 1),
new Result($facet->reveal(), 5, 5, 5),
];
$results[0]->setUrl(new Url('test'));
$results[1]->setUrl(new Url('test'));
......
......@@ -44,8 +44,8 @@ class SliderProcessorTest extends UnitTestCase {
$facet->setWidget('raw', $widgetconfig);
$this->configureContainer($widgetconfig);
$result_lower = new Result(5, '5', 1);
$result_higher = new Result(150, '150', 1);
$result_lower = new Result($facet, 5, '5', 1);
$result_higher = new Result($facet, 150, '150', 1);
$facet->setResults([$result_lower, $result_higher]);
// Process the data.
......@@ -76,11 +76,11 @@ class SliderProcessorTest extends UnitTestCase {
$facet->setWidget('raw', $widgetconfig);
$this->configureContainer($widgetconfig);
$original_results[] = new Result(1, 'Small', 5);
$original_results[] = new Result($facet, 1, 'Small', 5);
foreach (range(100, 100000, 10) as $k) {
$original_results[] = new Result($k, 'result ' . $k, 1);
$original_results[] = new Result($facet, $k, 'result ' . $k, 1);
}
$original_results[] = new Result(150000, 'Big', 5);
$original_results[] = new Result($facet, 150000, 'Big', 5);
$facet->setResults($original_results);
// Process the data.
......@@ -108,7 +108,7 @@ class SliderProcessorTest extends UnitTestCase {
$original_results = [];
foreach ([10, 100, 200, 5] as $k) {
$original_results[] = new Result($k, 'result ' . $k, 1);
$original_results[] = new Result($facet, $k, 'result ' . $k, 1);
}
$facet->setResults($original_results);
......@@ -137,8 +137,8 @@ class SliderProcessorTest extends UnitTestCase {
$facet->setWidget('raw', $widgetconfig);
$this->configureContainer($widgetconfig);
$result_lower = new Result(5, '5', 1);
$result_higher = new Result(150, '150', 1);
$result_lower = new Result($facet, 5, '5', 1);
$result_higher = new Result($facet, 150, '150', 1);
$facet->setResults([$result_lower, $result_higher]);
// Process the data.
......@@ -159,8 +159,8 @@ class SliderProcessorTest extends UnitTestCase {
$facet->setWidget('raw', $widgetconfig);
$this->configureContainer($widgetconfig);
$result_lower = new Result(5, '5', 4);
$result_higher = new Result(15, '15', 4);
$result_lower = new Result($facet, 5, '5', 4);
$result_higher = new Result($facet, 15, '15', 4);
$facet->setResults([$result_lower, $result_higher]);
// Process the data.
......
......@@ -78,16 +78,16 @@ class SliderWidgetTest extends WidgetTestBase {
$container->set('url_generator', $url_generator->reveal());
\Drupal::setContainer($container);
$facet = new Facet(['id' => 'barn_owl'], 'facets_facet');
$originalResults = [];
foreach (range(3, 20000, 2) as $rv) {
$res = new Result($rv, 'Value: ' . $rv, ceil($rv / 2));
$res = new Result($facet, $rv, 'Value: ' . $rv, ceil($rv / 2));
$res->setUrl(new Url('test'));
$originalResults[] = $res;
}
$this->originalResults = $originalResults;
$facet = new Facet(['id' => 'barn_owl'], 'facets_facet');
$facet->setResults($this->originalResults);
$facet->setFieldIdentifier('owl');
$facet->setWidget('slider', []);
......
......@@ -156,6 +156,8 @@ class DefaultFacetsSummaryManager {
'#show_count' => $show_count,
'#count' => $result->getCount(),
'#is_active' => TRUE,
'#facet' => $result->getFacet(),
'#raw_value' => $result->getRawValue(),
];
$item = (new Link($item, $result->getUrl()))->toRenderable();
$items[] = $item;
......
......@@ -71,7 +71,7 @@ class SearchApiRange extends QueryTypePluginBase {
if ($result['count'] || $query_operator == 'or') {
$count = $result['count'];
$result_filter = trim($result['filter'], '"');
$result = new Result($result_filter, $result_filter, $count);
$result = new Result($this->facet, $result_filter, $result_filter, $count);
$facet_results[] = $result;
}
}
......
......@@ -76,7 +76,7 @@ class SearchApiString extends QueryTypePluginBase {
if ($result['count'] || $query_operator == 'or') {
$count = $result['count'];
$result_filter = trim($result['filter'], '"');
$result = new Result($result_filter, $result_filter, $count);
$result = new Result($this->facet, $result_filter, $result_filter, $count);
$facet_results[] = $result;
}
}
......
......@@ -82,7 +82,7 @@ abstract class QueryTypeRangeBase extends QueryTypePluginBase {
);
}
else {
$facet_results[$result_filter['raw']] = new Result($result_filter['raw'], $result_filter['display'], $count);
$facet_results[$result_filter['raw']] = new Result($this->facet, $result_filter['raw'], $result_filter['display'], $count);
}
}
}
......
......@@ -3,12 +3,20 @@
namespace Drupal\facets\Result;
use Drupal\Core\Url;
use Drupal\facets\FacetInterface;
/**
* The default implementation of the result interfaces.
*/
class Result implements ResultInterface {
/**
* The facet related to the result.
*
* @var \Drupal\facets\FacetInterface
*/
protected $facet;
/**
* The facet value.
*
......@@ -54,6 +62,8 @@ class Result implements ResultInterface {
/**
* Constructs a new result value object.
*
* @param \Drupal\facets\FacetInterface $facet
* The facet related to the result.
* @param mixed $raw_value
* The raw value.
* @param mixed $display_value
......@@ -61,7 +71,8 @@ class Result implements ResultInterface {
* @param int|null $count
* The amount of items or NULL.
*/
public function __construct($raw_value, $display_value, $count) {
public function __construct(FacetInterface $facet, $raw_value, $display_value, $count) {
$this->facet = $facet;
$this->rawValue = $raw_value;
$this->displayValue = $display_value;
$this->count = (int) $count;
......@@ -159,4 +170,11 @@ class Result implements ResultInterface {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getFacet() {
return $this->facet;
}
}
......@@ -9,6 +9,14 @@ use Drupal\Core\Url;
*/
interface ResultInterface {
/**
* Returns the facet related to the result.
*
* @return \Drupal\facets\FacetInterface
* The facet related to the result.
*/
public function getFacet();
/**
* Returns the raw value as present in the index.
*
......
......@@ -62,6 +62,7 @@ abstract class WidgetPluginBase extends PluginBase implements WidgetPluginInterf
return [
'#theme' => $this->getFacetItemListThemeHook($facet),
'#facet' => $facet,
'#items' => $items,
'#attributes' => [
'data-drupal-facet-id' => $facet->id(),
......@@ -232,6 +233,8 @@ abstract class WidgetPluginBase extends PluginBase implements WidgetPluginInterf
'#value' => $result->getDisplayValue(),
'#show_count' => $this->getConfiguration()['show_numbers'] && ($count !== NULL),
'#count' => $count,
'#facet' => $result->getFacet(),
'#raw_value' => $result->getRawValue(),
];
}
......
......@@ -15,6 +15,9 @@
* string or render array.
* - context: A list of contextual data associated with the list. May contain:
* - list_style: The ID of the widget plugin this facet uses.
* - facet: The facet for this result item.
* - id: the machine name for the facet.
* - label: The facet label.
*
* @see facets_preprocess_facets_item_list()
*
......
......@@ -5,9 +5,13 @@
*
* Available variables:
* - value: The item value.
* - raw_value: The raw item value.
* - show_count: If this facet provides count.
* - count: The amount of results.
* - is_active: The item is active.
* - facet: The facet for this result item.
* - id: the machine name for the facet.
* - label: The facet label.
*
* @ingroup themeable
*/
......
......@@ -248,14 +248,14 @@ class FacetTest extends KernelTestBase {
* @covers ::isActiveValue
*/
public function testResults() {
$entity = new Facet([], 'facets_facet');
/** @var \Drupal\facets\Result\ResultInterface[] $results */
$results = [
new Result('llama', 'llama', 10),
new Result('badger', 'badger', 15),
new Result('owl', 'owl', 5),
new Result($entity, 'llama', 'llama', 10),
new Result($entity, 'badger', 'badger', 15),
new Result($entity, 'owl', 'owl', 5),
];
$entity = new Facet([], 'facets_facet');
$this->assertEmpty($entity->getResults());
$entity->setResults($results);
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\facets\Unit\Plugin\processor;
use Drupal\facets\Entity\Facet;
use Drupal\facets\Plugin\facets\processor\ActiveWidgetOrderProcessor;
use Drupal\facets\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -33,13 +34,14 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
/** @var \Drupal\facets\Result\Result[] $original_results */
$original_results = [
new Result('Boxer', 'Boxer', 10),
new Result('Old Major', 'Old Major', 3),
new Result('Minimus', 'Minimus', 60),
new Result('Mr Whymper', 'Mr. Whymper', 1),
new Result('Clover', 'Clover', 50),
new Result($facet, 'Boxer', 'Boxer', 10),
new Result($facet, 'Old Major', 'Old Major', 3),
new Result($facet, 'Minimus', 'Minimus', 60),
new Result($facet, 'Mr Whymper', 'Mr. Whymper', 1),
new Result($facet, 'Clover', 'Clover', 50),
];
$original_results[1]->setActiveState(TRUE);
......
......@@ -34,9 +34,10 @@ class BooleanItemProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result(0, 0, 10),
new Result(1, 1, 15),
new Result($facet, 0, 0, 10),
new Result($facet, 1, 1, 15),
];
$this->processor = new BooleanItemProcessor([], 'boolean_item_processor', []);
......
......@@ -35,10 +35,11 @@ class CountLimitProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result('llama', 'llama', 10),
new Result('badger', 'badger', 5),
new Result('duck', 'duck', 15),
new Result($facet, 'llama', 'llama', 10),
new Result($facet, 'badger', 'badger', 5),
new Result($facet, 'duck', 'duck', 15),
];
$processor_id = 'count_limit';
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\facets\Unit\Plugin\processor;
use Drupal\facets\Entity\Facet;
use Drupal\facets\Plugin\facets\processor\CountWidgetOrderProcessor;
use Drupal\facets\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -33,10 +34,11 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result('llama', 'llama', 10),
new Result('badger', 'badger', 5),
new Result('duck', 'duck', 15),
new Result($facet, 'llama', 'llama', 10),
new Result($facet, 'badger', 'badger', 5),
new Result($facet, 'duck', 'duck', 15),
];
$this->processor = new CountWidgetOrderProcessor([], 'count_widget_order', []);
......
......@@ -28,12 +28,13 @@ class DependentFacetProcessorTest extends UnitTestCase {
* {@inheritdoc}
*/
public function setUp() {
$facet = new Facet([], 'facets_facet');
$this->results = [
new Result('snow_owl', 'Snow owl', 2),
new Result('forest_owl', 'Forest owl', 3),
new Result('sand_owl', 'Sand owl', 8),
new Result('church_owl', 'Church owl', 1),
new Result('barn_owl', 'Barn owl', 1),
new Result($facet, 'snow_owl', 'Snow owl', 2),
new Result($facet, 'forest_owl', 'Forest owl', 3),
new Result($facet, 'sand_owl', 'Sand owl', 8),
new Result($facet, 'church_owl', 'Church owl', 1),
new Result($facet, 'barn_owl', 'Barn owl', 1),
];
}
......
......@@ -3,6 +3,7 @@
namespace Drupal\Tests\facets\Unit\Plugin\processor;
use Drupal\Component\Transliteration\TransliterationInterface;
use Drupal\facets\Entity\Facet;
use Drupal\facets\Plugin\facets\processor\DisplayValueWidgetOrderProcessor;
use Drupal\facets\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -34,14 +35,15 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result('thetans', 'thetans', 10),
new Result('xenu', 'xenu', 5),
new Result('Tom', 'Tom', 15),
new Result('Hubbard', 'Hubbard', 666),
new Result('FALSE', 'FALSE', 1),
new Result('1977', '1977', 20),
new Result('2', '2', 22),
new Result($facet, 'thetans', 'thetans', 10),
new Result($facet, 'xenu', 'xenu', 5),
new Result($facet, 'Tom', 'Tom', 15),
new Result($facet, 'Hubbard', 'Hubbard', 666),
new Result($facet, 'FALSE', 'FALSE', 1),
new Result($facet, '1977', '1977', 20),
new Result($facet, '2', '2', 22),
];
$transliteration = $this->getMockBuilder(TransliterationInterface::class)
......@@ -88,9 +90,10 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
* Tests that sorting uses the display value.
*/
public function testUseActualDisplayValue() {
$facet = new Facet([], 'facets_facet');
$original = [
new Result('bb_test', 'Test AA', 10),
new Result('aa_test', 'Test BB', 10),
new Result($facet, 'bb_test', 'Test AA', 10),
new Result($facet, 'aa_test', 'Test BB', 10),
];
$sorted_results = $this->processor->sortResults($original[0], $original[1]);
......
......@@ -35,17 +35,18 @@ class ExcludeSpecifiedItemsProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result('llama', 'llama', 10),
new Result('badger', 'badger', 5),
new Result('duck', 'duck', 15),
new Result('snbke', 'snbke', 10),
new Result('snake', 'snake', 10),
new Result('snaake', 'snaake', 10),
new Result('snaaake', 'snaaake', 10),
new Result('snaaaake', 'snaaaake', 10),
new Result('snaaaaake', 'snaaaaake', 10),
new Result('snaaaaaake', 'snaaaaaake', 10),
new Result($facet, 'llama', 'llama', 10),
new Result($facet, 'badger', 'badger', 5),
new Result($facet, 'duck', 'duck', 15),
new Result($facet, 'snbke', 'snbke', 10),
new Result($facet, 'snake', 'snake', 10),
new Result($facet, 'snaake', 'snaake', 10),
new Result($facet, 'snaaake', 'snaaake', 10),
new Result($facet, 'snaaaake', 'snaaaake', 10),
new Result($facet, 'snaaaaake', 'snaaaaake', 10),
new Result($facet, 'snaaaaaake', 'snaaaaaake', 10),
];
$processor_id = 'exclude_specified_items';
......
......@@ -34,10 +34,11 @@ class HideActiveItemsProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result('llama', 'llama', 10),
new Result('badger', 'badger', 15),
new Result('duck', 'duck', 15),
new Result($facet, 'llama', 'llama', 10),
new Result($facet, 'badger', 'badger', 15),
new Result($facet, 'duck', 'duck', 15),
];
$this->processor = new HideActiveItemsProcessor([], 'hide_non_narrowing_result_processor', []);
......
......@@ -34,10 +34,11 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result('llama', 'llama', 10),
new Result('badger', 'badger', 15),
new Result('duck', 'duck', 15),
new Result($facet, 'llama', 'llama', 10),
new Result($facet, 'badger', 'badger', 15),
new Result($facet, 'duck', 'duck', 15),
];
$this->processor = new HideNonNarrowingResultProcessor([], 'hide_non_narrowing_result_processor', []);
......
......@@ -39,10 +39,11 @@ class ListItemProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->results = [
new Result(1, 1, 10),
new Result(2, 2, 5),
new Result(3, 3, 15),
new Result($facet, 1, 1, 10),
new Result($facet, 2, 2, 5),
new Result($facet, 3, 3, 15),
];
$config_manager = $this->getMockBuilder(ConfigManager::class)
......
......@@ -2,6 +2,7 @@
namespace Drupal\Tests\facets\Unit\Plugin\processor;
use Drupal\facets\Entity\Facet;
use Drupal\facets\Plugin\facets\processor\RawValueWidgetOrderProcessor;
use Drupal\facets\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -33,14 +34,15 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result('C', 'thetans', 10),
new Result('B', 'xenu', 5),
new Result('A', 'Tom', 15),
new Result('D', 'Hubbard', 666),
new Result('E', 'FALSE', 1),
new Result('G', '1977', 20),
new Result('F', '2', 22),
new Result($facet, 'C', 'thetans', 10),
new Result($facet, 'B', 'xenu', 5),
new Result($facet, 'A', 'Tom', 15),
new Result($facet, 'D', 'Hubbard', 666),
new Result($facet, 'E', 'FALSE', 1),
new Result($facet, 'G', '1977', 20),
new Result($facet, 'F', '2', 22),
];
$this->processor = new RawValueWidgetOrderProcessor([], 'raw_value_widget_order', []);
......
......@@ -4,6 +4,7 @@ namespace Drupal\Tests\facets\Unit\Plugin\processor;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\facets\Entity\Facet;
use Drupal\facets\Plugin\facets\processor\TermWeightWidgetOrderProcessor;
use Drupal\facets\Result\Result;
use Drupal\taxonomy\Entity\Term;
......@@ -105,9 +106,10 @@ class TermWeightWidgetOrderProcessorTest extends UnitTestCase {
// Prepare the results that we use the processor to sort, the raw_value has
// to match the term_id keys used above in $terms. Display_value and count
// is not used.
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result(1, 10, 100),
new Result(2, 20, 200),
new Result($facet, 1, 10, 100),
new Result($facet, 2, 20, 200),
];
}
......
......@@ -109,7 +109,7 @@ class TranslateEntityProcessorTest extends UnitTestCase {
->method('getFieldIdentifier')
->willReturn('testfield');
$this->originalResults = [new Result(2, 2, 5)];
$this->originalResults = [new Result($this->facet, 2, 2, 5)];
$this->facet->setResults($this->originalResults);
// Mock language manager.
......
......@@ -59,11 +59,11 @@ class UidToUserNameCallbackProcessorTest extends UnitTestCase {
$container->set('entity_type.manager', $entity_manager);
\Drupal::setContainer($container);
$facet = new Facet([], 'facets_facet');
$original_results = [
new Result(1, 1, 5),
new Result($facet, 1, 1, 5),
];
$facet = new Facet([], 'facets_facet');
$facet->setResults($original_results);
$expected_results = [
......@@ -106,11 +106,11 @@ class UidToUserNameCallbackProcessorTest extends UnitTestCase {
$container->set('entity_type.manager', $entity_manager);
\Drupal::setContainer($container);
$facet = new Facet([], 'facets_facet');
$original_results = [
new Result(1, 1, 5),
new Result($facet, 1, 1, 5),
];
$facet = new Facet([], 'facets_facet');
$facet->setResults($original_results);
$filtered_results = $this->processor->build($facet, $original_results);
......
......@@ -39,12 +39,13 @@ class QueryStringTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
$this->originalResults = [
new Result('llama', 'Llama', 15),
new Result('badger', 'Badger', 5),
new Result('mushroom', 'Mushroom', 5),
new Result('duck', 'Duck', 15),
new Result('alpaca', 'Alpaca', 25),
new Result($facet, 'llama', 'Llama', 15),
new Result($facet, 'badger', 'Badger', 5),
new Result($facet, 'mushroom', 'Mushroom', 5),
new Result($facet, 'duck', 'Duck', 15),
new Result($facet, 'alpaca', 'Alpaca', 25),
];
$this->setContainer();
......
......@@ -25,7 +25,7 @@ class CheckboxWidgetTest extends WidgetTestBase {
* Tests widget without filters.
*/
public function testNoFilterResults() {
$facet = new Facet([], 'facets_facet');
$facet = $this->facet;
$facet->setResults($this->originalResults);
$output = $this->widget->build($facet);
......@@ -36,10 +36,10 @@ class CheckboxWidgetTest extends WidgetTestBase {
$this->assertEquals(['js-facets-checkbox-links'], $output['#attributes']['class']);
$expected_links = [
$this->buildLinkAssertion('Llama', 10),
$this->buildLinkAssertion('Badger', 20),
$this->buildLinkAssertion('Duck', 15),
$this->buildLinkAssertion('Alpaca', 9),
$this->buildLinkAssertion('Llama', 'llama', $facet, 10),
$this->buildLinkAssertion('Badger', 'badger', $facet, 20),
$this->buildLinkAssertion('Duck', 'duck', $facet, 15),
$this->buildLinkAssertion('Alpaca', 'alpaca', $facet, 9),
];