3 namespace Drupal\Tests\Core\PathProcessor;
5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\Config\ImmutableConfig;
7 use Drupal\Core\PathProcessor\PathProcessorFront;
8 use Drupal\Tests\UnitTestCase;
9 use Symfony\Component\HttpFoundation\Request;
10 use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
13 * Test front page path processing.
15 * @group PathProcessor
16 * @coversDefaultClass \Drupal\Core\PathProcessor\PathProcessorFront
18 class PathProcessorFrontTest extends UnitTestCase {
21 * Test basic inbound processing functionality.
23 * @covers ::processInbound
24 * @dataProvider providerProcessInbound
26 public function testProcessInbound($path, $expected) {
27 $config_factory = $this->prophesize(ConfigFactoryInterface::class);
28 $config = $this->prophesize(ImmutableConfig::class);
29 $config_factory->get('system.site')
30 ->willReturn($config->reveal());
31 $config->get('page.front')
32 ->willReturn('/node');
33 $processor = new PathProcessorFront($config_factory->reveal());
34 $this->assertEquals($expected, $processor->processInbound($path, new Request()));
38 * Inbound paths and expected results.
40 public function providerProcessInbound() {
48 * Test inbound failure with broken config.
50 * @covers ::processInbound
52 public function testProcessInboundBadConfig() {
53 $config_factory = $this->prophesize(ConfigFactoryInterface::class);
54 $config = $this->prophesize(ImmutableConfig::class);
55 $config_factory->get('system.site')
56 ->willReturn($config->reveal());
57 $config->get('page.front')
59 $processor = new PathProcessorFront($config_factory->reveal());
60 $this->setExpectedException(NotFoundHttpException::class);
61 $processor->processInbound('/', new Request());
65 * Test basic outbound processing functionality.
67 * @covers ::processOutbound
68 * @dataProvider providerProcessOutbound
70 public function testProcessOutbound($path, $expected) {
71 $config_factory = $this->prophesize(ConfigFactoryInterface::class);
72 $processor = new PathProcessorFront($config_factory->reveal());
73 $this->assertEquals($expected, $processor->processOutbound($path));
77 * Outbound paths and expected results.
79 public function providerProcessOutbound() {
82 ['<front>', '<front>'],