class RouteProcessorManagerTest
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php \Drupal\Tests\Core\RouteProcessor\RouteProcessorManagerTest
- 10 core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php \Drupal\Tests\Core\RouteProcessor\RouteProcessorManagerTest
- 11.x core/tests/Drupal/Tests/Core/RouteProcessor/RouteProcessorManagerTest.php \Drupal\Tests\Core\RouteProcessor\RouteProcessorManagerTest
@coversDefaultClass \Drupal\Core\RouteProcessor\RouteProcessorManager @group RouteProcessor
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait
- class \Drupal\Tests\Core\RouteProcessor\RouteProcessorManagerTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of RouteProcessorManagerTest
File
-
core/
tests/ Drupal/ Tests/ Core/ RouteProcessor/ RouteProcessorManagerTest.php, line 15
Namespace
Drupal\Tests\Core\RouteProcessorView source
class RouteProcessorManagerTest extends UnitTestCase {
/**
* The route processor manager.
*
* @var \Drupal\Core\RouteProcessor\RouteProcessorManager
*/
protected $processorManager;
/**
* {@inheritdoc}
*/
protected function setUp() : void {
$this->processorManager = new RouteProcessorManager();
}
/**
* Tests the Route process manager functionality.
*/
public function testRouteProcessorManager() {
$route = new Route('');
$parameters = [
'test' => 'test',
];
$route_name = 'test_name';
$processors = [
10 => $this->getMockProcessor($route_name, $route, $parameters),
5 => $this->getMockProcessor($route_name, $route, $parameters),
0 => $this->getMockProcessor($route_name, $route, $parameters),
];
// Add the processors in reverse order.
foreach ($processors as $priority => $processor) {
$this->processorManager
->addOutbound($processor, $priority);
}
$bubbleable_metadata = new BubbleableMetadata();
$this->processorManager
->processOutbound($route_name, $route, $parameters, $bubbleable_metadata);
// Default cacheability is: permanently cacheable, no cache tags/contexts.
$this->assertEquals((new BubbleableMetadata())->setCacheMaxAge(Cache::PERMANENT), $bubbleable_metadata);
}
/**
* Returns a mock Route processor object.
*
* @param string $route_name
* The route name.
* @param \Symfony\Component\Routing\Route $route
* The Route to use in mock with() expectation.
* @param array $parameters
* The parameters to use in mock with() expectation.
*
* @return \Drupal\Core\RouteProcessor\OutboundRouteProcessorInterface|\PHPUnit\Framework\MockObject\MockObject
*/
protected function getMockProcessor($route_name, $route, $parameters) {
$processor = $this->createMock('Drupal\\Core\\RouteProcessor\\OutboundRouteProcessorInterface');
$processor->expects($this->once())
->method('processOutbound')
->with($route_name, $route, $parameters);
return $processor;
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
PhpUnitWarnings::$deprecationWarnings | private static | property | Deprecation warnings from PHPUnit to raise with @trigger_error(). | |||
PhpUnitWarnings::addWarning | public | function | Converts PHPUnit deprecation warnings to E_USER_DEPRECATED. | |||
RouteProcessorManagerTest::$processorManager | protected | property | The route processor manager. | |||
RouteProcessorManagerTest::getMockProcessor | protected | function | Returns a mock Route processor object. | |||
RouteProcessorManagerTest::setUp | protected | function | Overrides UnitTestCase::setUp | |||
RouteProcessorManagerTest::testRouteProcessorManager | public | function | Tests the Route process manager functionality. | |||
UnitTestCase::$randomGenerator | protected | property | The random generator. | |||
UnitTestCase::$root | protected | property | The app root. | 1 | ||
UnitTestCase::assertArrayEquals | Deprecated | protected | function | Asserts if two arrays are equal by sorting them first. | ||
UnitTestCase::getClassResolverStub | protected | function | Returns a stub class resolver. | |||
UnitTestCase::getConfigFactoryStub | public | function | Returns a stub config factory that behaves according to the passed array. | |||
UnitTestCase::getConfigStorageStub | public | function | Returns a stub config storage that returns the supplied configuration. | |||
UnitTestCase::getContainerWithCacheTagsInvalidator | protected | function | Sets up a container with a cache tags invalidator. | |||
UnitTestCase::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |||
UnitTestCase::getStringTranslationStub | public | function | Returns a stub translation manager that just returns the passed string. | |||
UnitTestCase::randomMachineName | public | function | Generates a unique random string containing letters and numbers. | |||
UnitTestCase::setUpBeforeClass | public static | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.