MatcherDumper example

$this->fixtures = new RoutingFixtures();
    $this->state = new State(new KeyValueMemoryFactory());
    $this->logger = new TestLogger();
  }

  /** * Confirms that the dumper can be instantiated successfully. */
  public function testCreate() {
    $connection = Database::getConnection();
    $dumper = new MatcherDumper($connection$this->state, $this->logger);

    $class_name = 'Drupal\Core\Routing\MatcherDumper';
    $this->assertInstanceOf($class_name$dumper);
  }

  /** * Confirms that we can add routes to the dumper. */
  public function testAddRoutes() {
    $connection = Database::getConnection();
    $dumper = new MatcherDumper($connection$this->state, $this->logger);

    
protected function setUp():void {
    parent::setUp();
    $this->connection = $this->createMock(Connection::class);
    $this->state = $this->createMock(State::class);
  }

  /** * Tests the constructor deprecations. */
  public function testConstructorDeprecationNoLogger() {
    $this->expectDeprecation('Calling Drupal\Core\Routing\MatcherDumper::__construct() without the $logger argument is deprecated in drupal:10.1.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/2932520');
    $dumper = new MatcherDumper($this->connection, $this->state);
    $this->assertNotNull($dumper);
  }

  /** * Tests the constructor deprecations. */
  public function testConstructorDeprecationWithLegacyTableNameParam() {
    $this->expectDeprecation('Calling Drupal\Core\Routing\MatcherDumper::__construct() without the $logger argument is deprecated in drupal:10.1.0 and it will be required in drupal:11.0.0. See https://www.drupal.org/node/2932520');
    $dumper = new MatcherDumper($this->connection, $this->state, 'foo');
    $this->assertNotNull($dumper);
  }

  


  /** * Confirms that we can find routes with the exact incoming path. */
  public function testExactPathMatch() {
    $connection = Database::getConnection();
    $provider = new RouteProvider($connection$this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');

    $this->fixtures->createTables($connection);

    $dumper = new MatcherDumper($connection$this->state, $this->logger, 'test_routes');
    $dumper->addRoutes($this->fixtures->sampleRouteCollection());
    $dumper->dump();

    $path = '/path/one';

    $request = Request::create($path, 'GET');

    $routes = $provider->getRouteCollectionForRequest($request);

    foreach ($routes as $route) {
      $this->assertEquals($path$route->getPath(), 'Found path has correct pattern');
    }
Home | Imprint | This part of the site doesn't use cookies.