You are here

public function RouteProviderTest::testOutlinePathMatchZero in Zircon Profile 8

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

Tests a route with a 0 as value.

File

core/modules/system/src/Tests/Routing/RouteProviderTest.php, line 376
Contains \Drupal\system\Tests\Routing\RouteProviderTest.

Class

RouteProviderTest
Confirm that the default route provider is working correctly.

Namespace

Drupal\system\Tests\Routing

Code

public function testOutlinePathMatchZero() {
  $connection = Database::getConnection();
  $provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
  $this->fixtures
    ->createTables($connection);
  $collection = new RouteCollection();
  $collection
    ->add('poink', new Route('/some/path/{value}'));
  $dumper = new MatcherDumper($connection, $this->state, 'test_routes');
  $dumper
    ->addRoutes($collection);
  $dumper
    ->dump();
  $path = '/some/path/0';
  $request = Request::create($path, 'GET');
  try {
    $routes = $provider
      ->getRouteCollectionForRequest($request);

    // All of the matching paths have the correct pattern.
    foreach ($routes as $route) {
      $this
        ->assertEqual($route
        ->compile()
        ->getPatternOutline(), '/some/path/%', 'Found path has correct pattern');
    }
    $this
      ->assertEqual(count($routes), 1, 'The correct number of routes was found.');
  } catch (ResourceNotFoundException $e) {
    $this
      ->fail('No matchout route found with 0 as argument value');
  }
}