@covers ::processOutbound
File
-
tests/
src/ Unit/ SubPathautoTest.php, line 225
Class
- SubPathautoTest
- @coversDefaultClass \Drupal\subpathauto\PathProcessor @group subpathauto
Namespace
Drupal\Tests\subpathauto\UnitCode
public function testOutboundSubPath() : void {
$this->aliasProcessor
->expects($this->any())
->method('processOutbound')
->willReturnCallback([
$this,
'aliasByPathCallback',
]);
$this->subPathautoSettings
->expects($this->atLeastOnce())
->method('get')
->willReturn(0);
// Look up a subpath of the 'content/first-node' alias.
$processed = $this->pathProcessor
->processOutbound('/node/1/a');
$this->assertEquals('/content/first-node/a', $processed);
// Look up a multilevel subpath of the '/content/first-node' alias.
$processed = $this->pathProcessor
->processOutbound('/node/1/kittens/more-kittens');
$this->assertEquals('/content/first-node/kittens/more-kittens', $processed);
// Look up a subpath of the 'content/first-node-test' alias.
$processed = $this->pathProcessor
->processOutbound('/node/1/test/a');
$this->assertEquals('/content/first-node-test/a', $processed);
// Look up an admin sub-path of the 'content/first-node' alias without
// disabling sub-paths for admin.
$processed = $this->pathProcessor
->processOutbound('/node/1/edit');
$this->assertEquals('/content/first-node/edit', $processed);
// Look up an admin sub-path without disabling sub-paths for admin.
$processed = $this->pathProcessor
->processOutbound('/admin/modules');
$this->assertEquals('/malicious-path/modules', $processed);
}