class HideWhenNotRenderedProcessorTest in Facets 8
Class HideWhenNotRenderedProcessorTest.
@group facets @coversDefaultClass \Drupal\facets_summary\Plugin\facets_summary\processor\HideWhenNotRenderedProcessor
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\facets_summary\Unit\Plugin\Processor\HideWhenNotRenderedProcessorTest
Expanded class hierarchy of HideWhenNotRenderedProcessorTest
File
- modules/
facets_summary/ tests/ src/ Unit/ Plugin/ Processor/ HideWhenNotRenderedProcessorTest.php, line 18
Namespace
Drupal\Tests\facets_summary\Unit\Plugin\ProcessorView source
class HideWhenNotRenderedProcessorTest extends UnitTestCase {
/**
* The processor we're testing.
*
* @var \Drupal\facets_summary\Processor\ProcessorInterface|\Drupal\facets_summary\Processor\BuildProcessorInterface
*/
protected $processor;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->processor = new HideWhenNotRenderedProcessor([], 'hide_when_not_rendered', []);
}
/**
* Tests the is hidden method.
*
* @covers ::isHidden
*/
public function testIsHidden() {
$this
->assertFalse($this->processor
->isHidden());
}
/**
* Tests the is locked method.
*
* @covers ::isLocked
*/
public function testIsLocked() {
$this
->assertFalse($this->processor
->isLocked());
}
/**
* Tests the build method, containing the actual work of the processor.
*
* @covers ::build
*/
public function testBuild() {
$this
->createContainer(TRUE);
$summary = new FacetsSummary([], 'facets_summary');
$summary
->setFacetSourceId('foo');
$result = $this->processor
->build($summary, [
'foo',
], []);
$this
->assertEquals([
'foo',
], $result);
}
/**
* Tests the build method, containing the actual work of the processor.
*
* @covers ::build
*/
public function testBuildWithNoCurrentRequest() {
$this
->createContainer(FALSE);
$summary = new FacetsSummary([], 'facets_summary');
$summary
->setFacetSourceId('foo');
$result = $this->processor
->build($summary, [
'foo',
], []);
$this
->assertEquals([], $result);
}
/**
* Rendered in current request.
*
* @param bool $renderedInCurrentRequestValue
* The value for rendered in current request.
*/
protected function createContainer($renderedInCurrentRequestValue) {
$fsi = $this
->getMockBuilder(FacetSourcePluginInterface::class)
->disableOriginalConstructor()
->getMock();
$fsi
->method('isRenderedInCurrentRequest')
->willReturn($renderedInCurrentRequestValue);
$facetSourceManager = $this
->getMockBuilder(FacetSourcePluginManager::class)
->disableOriginalConstructor()
->getMock();
$facetSourceManager
->method('createInstance')
->willReturn($fsi);
$container = new ContainerBuilder();
$container
->set('plugin.manager.facets.facet_source', $facetSourceManager);
\Drupal::setContainer($container);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HideWhenNotRenderedProcessorTest:: |
protected | property | The processor we're testing. | |
HideWhenNotRenderedProcessorTest:: |
protected | function | Rendered in current request. | |
HideWhenNotRenderedProcessorTest:: |
public | function |
Overrides UnitTestCase:: |
|
HideWhenNotRenderedProcessorTest:: |
public | function | Tests the build method, containing the actual work of the processor. | |
HideWhenNotRenderedProcessorTest:: |
public | function | Tests the build method, containing the actual work of the processor. | |
HideWhenNotRenderedProcessorTest:: |
public | function | Tests the is hidden method. | |
HideWhenNotRenderedProcessorTest:: |
public | function | Tests the is locked method. | |
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. |