public function NestedMatcherTest::testNestedMatcher

Confirms we can nest multiple partial matchers.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Routing/NestedMatcherTest.php, line 51
Definition of Drupal\system\Tests\Routing\NestedMatcherTest.

Class

NestedMatcherTest
Basic tests for the NestedMatcher class.

Namespace

Drupal\system\Tests\Routing

Code

public function testNestedMatcher() {
  $matcher = new NestedMatcher();
  $matcher
    ->setInitialMatcher(new MockPathMatcher($this->fixtures
    ->sampleRouteCollection()));
  $matcher
    ->addPartialMatcher(new HttpMethodMatcher(), 1);
  $matcher
    ->setFinalMatcher(new FirstEntryFinalMatcher());
  $request = Request::create('/path/one', 'GET');
  $attributes = $matcher
    ->matchRequest($request);
  $this
    ->assertEqual($attributes['_route']
    ->getOption('_name'), 'route_a', 'The correct matching route was found.');
}