Commit e94e71ef authored by borisson_'s avatar borisson_

Cleanup unit tests documentation

parent efe3f545
......@@ -8,7 +8,6 @@
namespace Drupal\Tests\facetapi\Unit\Plugin\Processor;
use Drupal\facetapi\Plugin\facetapi\processor\ActiveWidgetOrderProcessor;
use Drupal\facetapi\Processor\WidgetOrderProcessorInterface;
use Drupal\facetapi\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -20,7 +19,7 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
/**
* The processor to be tested.
*
* @var WidgetOrderProcessorInterface
* @var \Drupal\facetapi\processor\WidgetOrderProcessorInterface
*/
protected $processor;
......@@ -37,7 +36,8 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
protected function setUp() {
parent::setUp();
$this->original_results = [
/** @var \Drupal\facetapi\Result\Result[] $original_results */
$original_results = [
new Result('Boxer', 'Boxer', 10),
new Result('Old Major', 'Old Major', 3),
new Result('Minimus', 'Minimus', 60),
......@@ -45,9 +45,11 @@ class ActiveWidgetOrderProcessorTest extends UnitTestCase {
new Result('Clover', 'Clover', 50),
];
$this->original_results[1]->setActiveState(true);
$this->original_results[2]->setActiveState(true);
$this->original_results[3]->setActiveState(true);
$original_results[1]->setActiveState(true);
$original_results[2]->setActiveState(true);
$original_results[3]->setActiveState(true);
$this->original_results = $original_results;
$this->processor = new ActiveWidgetOrderProcessor([], 'active_widget_order', []);
}
......
......@@ -8,7 +8,6 @@
namespace Drupal\Tests\facetapi\Unit\Plugin\Processor;
use Drupal\facetapi\Plugin\facetapi\processor\CountWidgetOrderProcessor;
use Drupal\facetapi\Processor\WidgetOrderProcessorInterface;
use Drupal\facetapi\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -20,7 +19,7 @@ class CountWidgetOrderProcessorTest extends UnitTestCase {
/**
* The processor to be tested.
*
* @var WidgetOrderProcessorInterface
* @var \Drupal\facetapi\processor\WidgetOrderProcessorInterface
*/
protected $processor;
......
......@@ -8,7 +8,6 @@
namespace Drupal\Tests\facetapi\Unit\Plugin\Processor;
use Drupal\facetapi\Plugin\facetapi\processor\DisplayValueWidgetOrderProcessor;
use Drupal\facetapi\Processor\WidgetOrderProcessorInterface;
use Drupal\facetapi\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -20,7 +19,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
/**
* The processor to be tested.
*
* @var WidgetOrderProcessorInterface
* @var \Drupal\facetapi\processor\WidgetOrderProcessorInterface
*/
protected $processor;
......@@ -55,7 +54,7 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
*/
public function testAscending() {
$sorted_results = $this->processor->sortResults($this->original_results, 'ASC');
$expected_values = array('2', '1977', 'FALSE', 'Hubbard', 'thetans', 'Tom', 'xenu');
$expected_values = ['2', '1977', 'FALSE', 'Hubbard', 'thetans', 'Tom', 'xenu'];
foreach ($expected_values as $index => $value) {
$this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
}
......@@ -66,12 +65,15 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
*/
public function testDescending() {
$sorted_results = $this->processor->sortResults($this->original_results, 'DESC');
$expected_values = array_reverse(array('2', '1977', 'FALSE', 'Hubbard', 'thetans', 'Tom', 'xenu'));
$expected_values = array_reverse(['2', '1977', 'FALSE', 'Hubbard', 'thetans', 'Tom', 'xenu']);
foreach ($expected_values as $index => $value) {
$this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
}
}
/**
* Test that sorting uses the display value.
*/
public function testUseActualDisplayValue() {
$original = [
new Result('bb_test', 'Test AA', 10),
......@@ -82,7 +84,6 @@ class DisplayValueWidgetOrderProcessorTest extends UnitTestCase {
$this->assertEquals('Test BB', $sorted_results[0]->getDisplayValue());
$this->assertEquals('Test AA', $sorted_results[1]->getDisplayValue());
}
}
......@@ -9,7 +9,6 @@ namespace Drupal\Tests\facetapi\Unit\Plugin\Processor;
use Drupal\facetapi\Entity\Facet;
use Drupal\facetapi\Plugin\facetapi\processor\HideNonNarrowingResultProcessor;
use Drupal\facetapi\Processor\WidgetOrderProcessorInterface;
use Drupal\facetapi\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -21,7 +20,7 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
/**
* The processor to be tested.
*
* @var WidgetOrderProcessorInterface
* @var \Drupal\facetapi\processor\WidgetOrderProcessorInterface
*/
protected $processor;
......@@ -83,7 +82,7 @@ class HideNonNarrowingResultProcessorTest extends UnitTestCase {
$this->assertCount(2, $filtered_results);
// Llama is shown because it does filtering.
// Llama is shown because it narrows results.
$this->assertEquals(10, $filtered_results[0]->getCount());
$this->assertEquals('llama', $filtered_results[0]->getDisplayValue());
......
......@@ -9,7 +9,6 @@ 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;
......@@ -21,7 +20,7 @@ class MinimumCountProcessorTest extends UnitTestCase {
/**
* The processor to be tested.
*
* @var BuildProcessorInterface
* @var \Drupal\facetapi\processor\BuildProcessorInterface
*/
protected $processor;
......@@ -64,9 +63,7 @@ class MinimumCountProcessorTest extends UnitTestCase {
$this->assertCount(2, $sorted_results);
$this->assertEquals(10, $sorted_results[0]->getCount());
$this->assertEquals('llama', $sorted_results[0]->getDisplayValue());
$this->assertEquals(15, $sorted_results[2]->getCount());
$this->assertEquals('duck', $sorted_results[2]->getDisplayValue());
}
......
......@@ -8,7 +8,6 @@
namespace Drupal\Tests\facetapi\Unit\Plugin\Processor;
use Drupal\facetapi\Plugin\facetapi\processor\RawValueWidgetOrderProcessor;
use Drupal\facetapi\Processor\WidgetOrderProcessorInterface;
use Drupal\facetapi\Result\Result;
use Drupal\Tests\UnitTestCase;
......@@ -20,7 +19,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
/**
* The processor to be tested.
*
* @var WidgetOrderProcessorInterface
* @var \Drupal\facetapi\processor\WidgetOrderProcessorInterface
*/
protected $processor;
......@@ -55,7 +54,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
*/
public function testAscending() {
$sorted_results = $this->processor->sortResults($this->original_results, 'ASC');
$expected_values = array('Tom', 'xenu', 'thetans', 'Hubbard', 'FALSE', '2', '1977');
$expected_values = ['Tom', 'xenu', 'thetans', 'Hubbard', 'FALSE', '2', '1977'];
foreach ($expected_values as $index => $value) {
$this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
}
......@@ -66,7 +65,7 @@ class RawValueWidgetOrderProcessorTest extends UnitTestCase {
*/
public function testDescending() {
$sorted_results = $this->processor->sortResults($this->original_results, 'DESC');
$expected_values = array_reverse(array('Tom', 'xenu', 'thetans', 'Hubbard', 'FALSE', '2', '1977'));
$expected_values = array_reverse(['Tom', 'xenu', 'thetans', 'Hubbard', 'FALSE', '2', '1977']);
foreach ($expected_values as $index => $value) {
$this->assertEquals($value, $sorted_results[$index]->getDisplayValue());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment