You are here

public function MatcherDumperTest::testMenuMasksGeneration in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Routing/MatcherDumperTest.php \Drupal\system\Tests\Routing\MatcherDumperTest::testMenuMasksGeneration()

Tests the determination of the masks generation.

File

core/modules/system/src/Tests/Routing/MatcherDumperTest.php, line 147
Contains \Drupal\system\Tests\Routing\MatcherDumperTest.

Class

MatcherDumperTest
Confirm that the matcher dumper is functioning properly.

Namespace

Drupal\system\Tests\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(array(
    'provider' => 'test',
  ));

  // Using binary for readability, we expect a 0 at any wildcard slug. They
  // should be ordered from longest to shortest.
  $expected = array(
    bindec('1011111'),
    bindec('10111'),
    bindec('111'),
    bindec('101'),
  );
  $this
    ->assertEqual($this->state
    ->get('routing.menu_masks.test_routes'), $expected);
}