@covers ::processInbound
File
-
tests/
src/ Unit/ SubPathautoTest.php, line 150
Class
- SubPathautoTest
- @coversDefaultClass \Drupal\subpathauto\PathProcessor @group subpathauto
Namespace
Drupal\Tests\subpathauto\UnitCode
public function testInboundSubPath() : void {
$this->aliasProcessor
->expects($this->any())
->method('processInbound')
->willReturnCallback([
$this,
'pathAliasCallback',
]);
$this->pathValidator
->expects($this->any())
->method('getUrlIfValidWithoutAccessCheck')
->willReturn(new Url('any_route'));
$this->subPathautoSettings
->expects($this->atLeastOnce())
->method('get')
->willReturn(0);
// Look up a subpath of the 'content/first-node' alias.
$processed = $this->pathProcessor
->processInbound('/content/first-node/a', Request::create('/content/first-node/a'));
$this->assertEquals('/node/1/a', $processed);
// Look up a subpath of the 'content/first-node' alias when request has
// language prefix.
$processed = $this->pathProcessor
->processInbound('/content/first-node/a', Request::create('/default_language/content/first-node/a'));
$this->assertEquals('/node/1/a', $processed);
// Look up a multilevel subpath of the '/content/first-node' alias.
$processed = $this->pathProcessor
->processInbound('/content/first-node/kittens/more-kittens', Request::create('/content/first-node/kittens/more-kittens'));
$this->assertEquals('/node/1/kittens/more-kittens', $processed);
// Look up a subpath of the 'content/first-node-test' alias.
$processed = $this->pathProcessor
->processInbound('/content/first-node-test/a', Request::create('/content/first-node-test/a'));
$this->assertEquals('/node/1/test/a', $processed);
// Look up an admin sub-path of the 'content/first-node' alias without
// disabling sub-paths for admin.
$processed = $this->pathProcessor
->processInbound('/content/first-node/edit', Request::create('/content/first-node/edit'));
$this->assertEquals('/node/1/edit', $processed);
// Look up an admin sub-path without disabling sub-paths for admin.
$processed = $this->pathProcessor
->processInbound('/malicious-path/modules', Request::create('/malicious-path/modules'));
$this->assertEquals('/admin/modules', $processed);
}