public function QueryStringTest::testUnroutedPath in Facets 8
Tests that unrouted paths can be handled properly.
File
- tests/
src/ Unit/ Plugin/ url_processor/ QueryStringTest.php, line 373
Class
- QueryStringTest
- Unit test for processor.
Namespace
Drupal\Tests\facets\Unit\Plugin\url_processorCode
public function testUnroutedPath() {
// Override router.
$router = $this
->getMockBuilder(TestRouterInterface::class)
->disableOriginalConstructor()
->getMock();
$router
->expects($this
->any())
->method('matchRequest')
->willThrowException(new ResourceNotFoundException());
// Get the container from the setUp method and change it with the
// implementation created here, that has the route parameters.
$container = \Drupal::getContainer();
$container
->set('router.no_access_checks', $router);
\Drupal::setContainer($container);
// Create facet.
$facet = new Facet([], 'facets_facet');
$facet
->setFieldIdentifier('test');
$facet
->setUrlAlias('test');
$facet
->setFacetSourceId('facet_source__dummy');
$this->processor = new QueryString([
'facet' => $facet,
], 'query_string', [], new Request(), $this->entityManager, $this->eventDispatcher);
$results = $this->processor
->buildUrls($facet, $this->originalResults);
foreach ($results as $result) {
$this
->assertEquals('base:test', $result
->getUrl()
->getUri());
}
}