public function MatcherDumperTest::testMenuMasksGeneration in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php \Drupal\KernelTests\Core\Routing\MatcherDumperTest::testMenuMasksGeneration()
- 9 core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php \Drupal\KernelTests\Core\Routing\MatcherDumperTest::testMenuMasksGeneration()
Tests the determination of the masks generation.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Routing/ MatcherDumperTest.php, line 141
Class
- MatcherDumperTest
- Confirm that the matcher dumper is functioning properly.
Namespace
Drupal\KernelTests\Core\RoutingCode
public function testMenuMasksGeneration() {
$connection = Database::getConnection();
$dumper = new MatcherDumper($connection, $this->state, 'test_routes');
$collection = new RouteCollection();
$collection
->add('test_route_1', new Route('/test-length-3/{my}/path'));
$collection
->add('test_route_2', new Route('/test-length-3/hello/path'));
$collection
->add('test_route_3', new Route('/test-length-5/{my}/path/marvin/magrathea'));
$collection
->add('test_route_4', new Route('/test-length-7/{my}/path/marvin/magrathea/earth/ursa-minor'));
$dumper
->addRoutes($collection);
$this->fixtures
->createTables($connection);
$dumper
->dump([
'provider' => 'test',
]);
// Using binary for readability, we expect a 0 at any wildcard slug. They
// should be ordered from longest to shortest.
$expected = [
bindec('1011111'),
bindec('10111'),
bindec('111'),
bindec('101'),
];
$this
->assertEquals($expected, $this->state
->get('routing.menu_masks.test_routes'));
}