public function FirstEntryFinalMatcherTest::testFinalMatcherPatternDefalts

Confirms the final matcher returns correct attributes with default values.

File

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

Class

FirstEntryFinalMatcherTest
Basic tests for the NestedMatcher class.

Namespace

Drupal\system\Tests\Routing

Code

public function testFinalMatcherPatternDefalts() {
  $collection = new RouteCollection();
  $collection
    ->add('route_a', new Route('/path/one/{value}', array(
    '_controller' => 'foo',
    'value' => 'poink',
  )));
  $request = Request::create('/path/one', 'GET');
  $request->attributes
    ->set('system_path', 'path/one');
  $matcher = new FirstEntryFinalMatcher();
  $matcher
    ->setCollection($collection);
  $attributes = $matcher
    ->matchRequest($request);
  $this
    ->assertEqual($attributes['_route']
    ->getOption('_name'), 'route_a', 'The correct matching route was found.');
  $this
    ->assertEqual($attributes['_controller'], 'foo', 'The correct controller was found.');
  $this
    ->assertEqual($attributes['value'], 'poink', 'Optional placeholder value used default.');
}