class ActiveWidgetOrderProcessorTest in Facets 8
Unit test for processor.
@group facets
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\facets\Unit\Plugin\processor\ActiveWidgetOrderProcessorTest
Expanded class hierarchy of ActiveWidgetOrderProcessorTest
File
- tests/
src/ Unit/ Plugin/ processor/ ActiveWidgetOrderProcessorTest.php, line 15
Namespace
Drupal\Tests\facets\Unit\Plugin\processorView source
class ActiveWidgetOrderProcessorTest extends UnitTestCase {
/**
* The processor to be tested.
*
* @var \Drupal\facets\Processor\SortProcessorInterface
*/
protected $processor;
/**
* An array containing the results before the processor has ran.
*
* @var \Drupal\facets\Result\Result[]
*/
protected $originalResults;
/**
* Creates a new processor object for use in the tests.
*/
protected function setUp() {
parent::setUp();
$facet = new Facet([], 'facets_facet');
/** @var \Drupal\facets\Result\Result[] $original_results */
$original_results = [
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);
$original_results[2]
->setActiveState(TRUE);
$original_results[3]
->setActiveState(TRUE);
$this->originalResults = $original_results;
$this->processor = new ActiveWidgetOrderProcessor([], 'active_widget_order', []);
}
/**
* Tests sorting.
*/
public function testSorting() {
$sort_value = $this->processor
->sortResults($this->originalResults[0], $this->originalResults[1]);
$this
->assertEquals(1, $sort_value);
$sort_value = $this->processor
->sortResults($this->originalResults[1], $this->originalResults[2]);
$this
->assertEquals(0, $sort_value);
$sort_value = $this->processor
->sortResults($this->originalResults[2], $this->originalResults[3]);
$this
->assertEquals(0, $sort_value);
$sort_value = $this->processor
->sortResults($this->originalResults[3], $this->originalResults[4]);
$this
->assertEquals(-1, $sort_value);
$sort_value = $this->processor
->sortResults($this->originalResults[3], $this->originalResults[3]);
$this
->assertEquals(0, $sort_value);
}
/**
* Tests configuration.
*/
public function testDefaultConfiguration() {
$config = $this->processor
->defaultConfiguration();
$this
->assertEquals([
'sort' => 'DESC',
], $config);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ActiveWidgetOrderProcessorTest:: |
protected | property | An array containing the results before the processor has ran. | |
ActiveWidgetOrderProcessorTest:: |
protected | property | The processor to be tested. | |
ActiveWidgetOrderProcessorTest:: |
protected | function |
Creates a new processor object for use in the tests. Overrides UnitTestCase:: |
|
ActiveWidgetOrderProcessorTest:: |
public | function | Tests configuration. | |
ActiveWidgetOrderProcessorTest:: |
public | function | Tests sorting. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |