public function QueryStringTest::testSetSingleActiveItem in Facets 8
Tests with one active item.
File
- tests/
src/ Unit/ Plugin/ url_processor/ QueryStringTest.php, line 91
Class
- QueryStringTest
- Unit test for processor.
Namespace
Drupal\Tests\facets\Unit\Plugin\url_processorCode
public function testSetSingleActiveItem() {
$facet = new Facet([], 'facets_facet');
$facet
->setResults($this->originalResults);
$facet
->setUrlAlias('test');
$facet
->setFieldIdentifier('test');
$discovery_property = new \ReflectionProperty($facet, 'id');
$discovery_property
->setAccessible(TRUE);
$discovery_property
->setValue($facet, 'test');
$storage = $this
->createMock(EntityStorageInterface::class);
$storage
->expects($this
->any())
->method('loadByProperties')
->willReturn([
$facet,
]);
$entityTypeManager = $this
->getMockBuilder(EntityTypeManagerInterface::class)
->disableOriginalConstructor()
->getMock();
$entityTypeManager
->expects($this
->any())
->method('getStorage')
->willReturn($storage);
$container = \Drupal::getContainer();
$container
->set('entity_type.manager', $entityTypeManager);
\Drupal::setContainer($container);
$request = new Request();
$request->query
->set('f', [
'test:badger',
]);
$this->processor = new QueryString([
'facet' => $facet,
], 'query_string', [], $request, $entityTypeManager, $this->eventDispatcher);
$this->processor
->setActiveItems($facet);
$this
->assertEquals([
'badger',
], $facet
->getActiveItems());
}