function AttributeRouteDiscoveryTest::testOnRouteBuild

Same name and namespace in other branches
  1. main core/tests/Drupal/Tests/Core/Routing/AttributeRouteDiscoveryTest.php \Drupal\Tests\Core\Routing\AttributeRouteDiscoveryTest::testOnRouteBuild()

@legacy-covers ::onRouteBuild

File

core/tests/Drupal/Tests/Core/Routing/AttributeRouteDiscoveryTest.php, line 48

Class

AttributeRouteDiscoveryTest
Tests \Drupal\Core\Routing\AttributeRouteDiscovery.

Namespace

Drupal\Tests\Core\Routing

Code

public function testOnRouteBuild() : void {
  $this->assertNotEmpty($this->routeCollection);
  $route1 = $this->routeCollection
    ->get('router_test.method_attribute');
  $this->assertNotNull($route1);
  $this->assertSame('/test_method_attribute', $route1->getPath());
  $this->assertSame(TestAttributes::class . '::attributeMethod', $route1->getDefault('_controller'));
  $this->assertSame("TRUE", $route1->getRequirement('_access'));
  $this->assertSame($route1, $this->routeCollection
    ->get('router_test.alias_test'));
  $route2 = $this->routeCollection
    ->get('router_test.class_invoke');
  $this->assertNotNull($route2);
  $this->assertSame('/test_class_attribute', $route2->getPath());
  $this->assertSame(TestClassAttribute::class, $route2->getDefault('_controller'));
  $this->assertSame("TRUE", $route2->getRequirement('_access'));
  $this->assertSame($route2, $this->routeCollection
    ->get(TestClassAttribute::class . '::__invoke'));
  $route3 = $this->routeCollection
    ->get('router_test.method_attribute_other');
  $this->assertNotNull($route3);
  $this->assertSame('/test_method_attribute-other-path', $route3->getPath());
  $this->assertSame(TestAttributes::class . '::attributeMethod', $route3->getDefault('_controller'));
  $this->assertSame("TRUE", $route3->getRequirement('_access'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.