class BooleanItemProcessorTest 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\BooleanItemProcessorTest
Expanded class hierarchy of BooleanItemProcessorTest
File
- tests/
src/ Unit/ Plugin/ processor/ BooleanItemProcessorTest.php, line 15
Namespace
Drupal\Tests\facets\Unit\Plugin\processorView source
class BooleanItemProcessorTest extends UnitTestCase {
/**
* The processor to be tested.
*
* @var \Drupal\facets\processor\BuildProcessorInterface
*/
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');
$this->originalResults = [
new Result($facet, 0, 0, 10),
new Result($facet, 1, 1, 15),
];
$this->processor = new BooleanItemProcessor([], 'boolean_item_processor', []);
}
/**
* Tests filtering of results.
*/
public function testBuild() {
$facet = new Facet([], 'facets_facet');
$facet
->setResults($this->originalResults);
$filtered_results = $this->processor
->build($facet, $this->originalResults);
// The default values for on / off are On and Off.
$this
->assertEquals('Off', $filtered_results[0]
->getDisplayValue());
$this
->assertEquals('On', $filtered_results[1]
->getDisplayValue());
// Overwrite the on/off values.
$configuration = [
'on_value' => 'True',
'off_value' => 'False',
];
$this->processor
->setConfiguration($configuration);
$filtered_results = $this->processor
->build($facet, $this->originalResults);
$this
->assertEquals('False', $filtered_results[0]
->getDisplayValue());
$this
->assertEquals('True', $filtered_results[1]
->getDisplayValue());
}
/**
* Tests configuration.
*/
public function testConfiguration() {
$config = $this->processor
->defaultConfiguration();
$this
->assertEquals([
'on_value' => 'On',
'off_value' => 'Off',
], $config);
}
/**
* Tests testDescription().
*/
public function testDescription() {
$this
->assertEquals('', $this->processor
->getDescription());
}
/**
* Tests isHidden().
*/
public function testIsHidden() {
$this
->assertEquals(FALSE, $this->processor
->isHidden());
}
/**
* Tests isLocked().
*/
public function testIsLocked() {
$this
->assertEquals(FALSE, $this->processor
->isLocked());
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BooleanItemProcessorTest:: |
protected | property | An array containing the results before the processor has ran. | |
BooleanItemProcessorTest:: |
protected | property | The processor to be tested. | |
BooleanItemProcessorTest:: |
protected | function |
Creates a new processor object for use in the tests. Overrides UnitTestCase:: |
|
BooleanItemProcessorTest:: |
public | function | Tests filtering of results. | |
BooleanItemProcessorTest:: |
public | function | Tests configuration. | |
BooleanItemProcessorTest:: |
public | function | Tests testDescription(). | |
BooleanItemProcessorTest:: |
public | function | Tests isHidden(). | |
BooleanItemProcessorTest:: |
public | function | Tests isLocked(). | |
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. |