class PathProcessorAliasTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorAliasTest.php \Drupal\Tests\Core\PathProcessor\PathProcessorAliasTest
@coversDefaultClass \Drupal\Core\PathProcessor\PathProcessorAlias @group PathProcessor
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\Core\PathProcessor\PathProcessorAliasTest
Expanded class hierarchy of PathProcessorAliasTest
File
- core/
tests/ Drupal/ Tests/ Core/ PathProcessor/ PathProcessorAliasTest.php, line 20 - Contains \Drupal\Tests\Core\PathProcessor\PathProcessorAliasTest.
Namespace
Drupal\Tests\Core\PathProcessorView source
class PathProcessorAliasTest extends UnitTestCase {
/**
* The mocked alias manager.
*
* @var \Drupal\Core\Path\AliasManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $aliasManager;
/**
* The tested path processor.
*
* @var \Drupal\Core\PathProcessor\PathProcessorAlias
*/
protected $pathProcessor;
protected function setUp() {
$this->aliasManager = $this
->getMock('Drupal\\Core\\Path\\AliasManagerInterface');
$this->pathProcessor = new PathProcessorAlias($this->aliasManager);
}
/**
* Tests the processInbound method.
*
* @see \Drupal\Core\PathProcessor\PathProcessorAlias::processInbound
*/
public function testProcessInbound() {
$this->aliasManager
->expects($this
->exactly(2))
->method('getPathByAlias')
->will($this
->returnValueMap(array(
array(
'urlalias',
NULL,
'internal-url',
),
array(
'url',
NULL,
'url',
),
)));
$request = Request::create('/urlalias');
$this
->assertEquals('internal-url', $this->pathProcessor
->processInbound('urlalias', $request));
$request = Request::create('/url');
$this
->assertEquals('url', $this->pathProcessor
->processInbound('url', $request));
}
/**
* @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);
}
/**
* @return array
*/
public function providerTestProcessOutbound() {
return [
[
'internal-url',
[],
'urlalias',
],
[
'internal-url',
[
'alias' => TRUE,
],
'internal-url',
],
[
'url',
[],
'url',
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
PathProcessorAliasTest:: |
protected | property | The mocked alias manager. | |
PathProcessorAliasTest:: |
protected | property | The tested path processor. | |
PathProcessorAliasTest:: |
public | function | ||
PathProcessorAliasTest:: |
protected | function |
Overrides UnitTestCase:: |
|
PathProcessorAliasTest:: |
public | function | Tests the processInbound method. | |
PathProcessorAliasTest:: |
public | function | @covers ::processOutbound | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |