summaryrefslogtreecommitdiffstats
path: root/tests/src/Unit/Plugin
diff options
context:
space:
mode:
authormollux2015-10-22 20:04:26 (GMT)
committerJoris Vercammen2015-10-22 20:04:26 (GMT)
commitc9d5765d6da357be41101d862f929e1f3a6fad73 (patch)
tree5c45d03cc3ff5c3ce12126699a5d7401219fb285 /tests/src/Unit/Plugin
parentb5b4880261e6456387b71b51b02be68a3dfac52f (diff)
Issue #2598298 by mollux, borisson_: Create Facet processors - Do now show facet with only X items
Diffstat (limited to 'tests/src/Unit/Plugin')
-rw-r--r--tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php b/tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php
new file mode 100644
index 0000000..bdc55fd
--- /dev/null
+++ b/tests/src/Unit/Plugin/processor/MinimumCountProcessorTest.php
@@ -0,0 +1,73 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\facetapi\Plugin\Processor\MinimumCountProcessorTest.
+ */
+
+namespace Drupal\Tests\facetapi\Unit\Plugin\Processor;
+
+use Drupal\facetapi\Entity\Facet;
+use Drupal\facetapi\Plugin\facetapi\processor\MinimumCountProcessor;
+use Drupal\facetapi\Processor\BuildProcessorInterface;
+use Drupal\facetapi\Result\Result;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * @group facetapi
+ */
+class MinimumCountProcessorTest extends UnitTestCase {
+
+ /**
+ * The processor to be tested.
+ *
+ * @var BuildProcessorInterface
+ */
+ protected $processor;
+
+ /**
+ * An array containing the results before the processor has ran.
+ *
+ * @var \Drupal\facetapi\Result\Result[]
+ */
+ protected $original_results;
+
+ /**
+ * Creates a new processor object for use in the tests.
+ */
+ protected function setUp() {
+ parent::setUp();
+
+ $this->original_results = [
+ new Result('llama', 10),
+ new Result('badger', 5),
+ new Result('duck', 15),
+ ];
+
+ $this->processor = new MinimumCountProcessor([], 'minimum_count', []);
+ }
+
+ /**
+ * Test filtering of results
+ */
+ public function testFilterResults() {
+
+ $facet = new Facet([], 'facet');
+ $facet->setResults($this->original_results);
+ $facet->setProcessorConfigs([
+ 'minimum_count' => [
+ 'settings' => ['minimum_items' => 6]
+ ]
+ ]);
+
+ $sorted_results = $this->processor->build($facet, $this->original_results);
+
+ $this->assertCount(2, $sorted_results);
+
+ $this->assertEquals(10, $sorted_results[0]->getCount());
+ $this->assertEquals('llama', $sorted_results[0]->getValue());
+ $this->assertEquals(15, $sorted_results[2]->getCount());
+ $this->assertEquals('duck', $sorted_results[2]->getValue());
+ }
+
+}