/** * Tests the processOutbound method. * * @see \Drupal\Core\PathProcessor\PathProcessorAlias::processOutbound */ public function testProcessOutbound() { $this->aliasManager->expects($this->exactly(2))->method('getAliasByPath')->will($this->returnValueMap(array(array('internal-url', NULL, 'urlalias'), array('url', NULL, 'url')))); $this->assertEquals('urlalias', $this->pathProcessor->processOutbound('internal-url')); $options = array('alias' => TRUE); $this->assertEquals('internal-url', $this->pathProcessor->processOutbound('internal-url', $options)); $this->assertEquals('url', $this->pathProcessor->processOutbound('url')); }
/** * @covers ::processOutbound * * @dataProvider providerTestProcessOutbound */ public function testProcessOutbound($path, array $options, $expected_path) { $this->aliasManager->expects($this->any())->method('getAliasByPath')->will($this->returnValueMap(array(array('internal-url', NULL, 'urlalias'), array('url', NULL, 'url')))); $bubbleable_metadata = new BubbleableMetadata(); $this->assertEquals($expected_path, $this->pathProcessor->processOutbound($path, $options, NULL, $bubbleable_metadata)); // Cacheability of paths replaced with path aliases is permanent. // @todo https://www.drupal.org/node/2480077 $this->assertEquals((new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT), $bubbleable_metadata); }
/** * @covers ::processOutbound */ public function testOutboundPathProcessorMaxDepth() { $this->pathValidator->expects($this->any()) ->method('getUrlIfValidWithoutAccessCheck') ->willReturn(new Url('any_route')); $this->subPathautoSettings->expects($this->exactly(2)) ->method('get') ->willReturn(3); $this->aliasProcessor->expects($this->any()) ->method('processOutbound') ->will($this->returnCallback([$this, 'aliasByPathCallback'])); // Subpath shouldn't be processed since the iterations has been limited. $processed = $this->sut->processOutbound('/node/1/first/second/third/fourth'); $this->assertEquals('/node/1/first/second/third/fourth', $processed); // Subpath should be processed when the max depth doesn't exceed. $processed = $this->sut->processOutbound('/node/1/first/second/third'); $this->assertEquals('/content/first-node/first/second/third', $processed); }