function MatcherDumperTest::testMenuMasksGeneration

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Routing/MatcherDumperTest.php \Drupal\KernelTests\Core\Routing\MatcherDumperTest::testMenuMasksGeneration()
  2. 10 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 135

Class

MatcherDumperTest
Confirm that the matcher dumper is functioning properly.

Namespace

Drupal\KernelTests\Core\Routing

Code

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->assertEqual($this->state
        ->get('routing.menu_masks.test_routes'), $expected);
}

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