class UnsupportedRouteAttributePropertiesTest

Same name and namespace in other branches
  1. main core/tests/Drupal/Tests/Core/Routing/UnsupportedRouteAttributePropertiesTest.php \Drupal\Tests\Core\Routing\UnsupportedRouteAttributePropertiesTest

Tests \Drupal\Core\Routing\AttributeRouteDiscovery.

Attributes

#[CoversClass(AttributeRouteDiscovery::class)] #[Group('Routing')]

Hierarchy

Expanded class hierarchy of UnsupportedRouteAttributePropertiesTest

File

core/tests/Drupal/Tests/Core/Routing/UnsupportedRouteAttributePropertiesTest.php, line 18

Namespace

Drupal\Tests\Core\Routing
View source
class UnsupportedRouteAttributePropertiesTest extends UnitTestCase {
  
  /**
   * @legacy-covers ::createRouteCollection
   */
  public function testException(string $class, string $message) : void {
    $discovery = new AttributeRouteDiscovery(new \ArrayIterator());
    $reflection = new \ReflectionClass($discovery);
    $method = $reflection->getMethod('createRouteCollection');
    $this->expectException(UnsupportedRouteAttributePropertyException::class);
    $this->expectExceptionMessage($message);
    $method->invoke($discovery, $class);
  }
  public static function providerTestException() : array {
    return [
      'method: missing_name' => [
        MethodRouteMissingName::class,
        'The Route attribute on "Drupal\\Tests\\Core\\Routing\\MethodRouteMissingName::attributeMethod()" is missing a required "name" property.',
      ],
      'method: locale' => [
        MethodRouteLocale::class,
        'The "locale" route attribute is not supported on route "MethodRouteLocale" in "Drupal\\Tests\\Core\\Routing\\MethodRouteLocale::attributeMethod()"',
      ],
      'method: localized_paths' => [
        MethodRouteLocalizedPaths::class,
        'The "path" route attribute does not support arrays on route "MethodRouteLocalizedPaths" in "Drupal\\Tests\\Core\\Routing\\MethodRouteLocalizedPaths::attributeMethod()"',
      ],
      'method: condition' => [
        MethodRouteCondition::class,
        'The "condition" route attribute is not supported on route "MethodRouteCondition" in "Drupal\\Tests\\Core\\Routing\\MethodRouteCondition::attributeMethod()"',
      ],
      'class: locale' => [
        ClassRouteLocale::class,
        'The "locale" route attribute is not supported in class "Drupal\\Tests\\Core\\Routing\\ClassRouteLocale"',
      ],
      'class: localized_paths' => [
        ClassRouteLocalizedPaths::class,
        'The "path" route attribute does not support arrays in class "Drupal\\Tests\\Core\\Routing\\ClassRouteLocalizedPaths"',
      ],
      'class: condition' => [
        ClassRouteCondition::class,
        'The "condition" route attribute is not supported in class "Drupal\\Tests\\Core\\Routing\\ClassRouteCondition"',
      ],
    ];
  }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overrides
DrupalTestCaseTrait::checkErrorHandlerOnTearDown public function Checks the test error handler after test execution. 1
ExpectDeprecationTrait::expectDeprecation Deprecated public function Adds an expected deprecation.
ExpectDeprecationTrait::regularExpressionForFormatDescription private function
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
UnitTestCase::$root protected property The app root.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::setDebugDumpHandler public static function Registers the dumper CLI handler when the DebugDump extension is enabled.
UnitTestCase::setUp protected function 371
UnitTestCase::setupMockIterator protected function Set up a traversable class mock to return specific items when iterated.
UnsupportedRouteAttributePropertiesTest::providerTestException public static function
UnsupportedRouteAttributePropertiesTest::testException public function @legacy-covers ::createRouteCollection

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