function MatcherDumperTest::testMenuMasksGeneration

Same name in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php \Drupal\KernelTests\Core\Routing\MatcherDumperTest::testMenuMasksGeneration()
  2. 8.9.x core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php \Drupal\KernelTests\Core\Routing\MatcherDumperTest::testMenuMasksGeneration()
  3. 11.x 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 157

Class

MatcherDumperTest
Confirm that the matcher dumper is functioning properly.

Namespace

Drupal\KernelTests\Core\Routing

Code

public function testMenuMasksGeneration() : void {
    $connection = Database::getConnection();
    $dumper = new MatcherDumper($connection, $this->state, $this->logger, '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/android'));
    $collection->add('test_route_4', new Route('/test-length-7/{my}/path/marvin/android/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'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.