class UnsupportedRouteAttributePropertiesTest
Same name and namespace in other branches
- 11.x 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
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Routing\UnsupportedRouteAttributePropertiesTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of UnsupportedRouteAttributePropertiesTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Routing/ UnsupportedRouteAttributePropertiesTest.php, line 20
Namespace
Drupal\Tests\Core\RoutingView source
class UnsupportedRouteAttributePropertiesTest extends UnitTestCase {
/**
* @legacy-covers ::createRouteCollection
*/
public function testException(string $class, string $message, bool $isForm = FALSE) : void {
$discovery = new AttributeRouteDiscovery(new \ArrayIterator());
$reflection = new \ReflectionClass($discovery);
$method = $reflection->getMethod($isForm ? 'createFormRouteCollection' : 'createControllerRouteCollection');
$this->expectException(UnsupportedRouteAttributePropertyException::class);
$this->expectExceptionMessage($message);
$method->invoke($discovery, new \ReflectionClass($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"',
],
'form_class: name' => [
FormClassMissingName::class,
'The Route attribute on "Drupal\\Tests\\Core\\Routing\\FormClassMissingName" is missing a required "name" property.',
TRUE,
],
'form_class: locale' => [
FormClassRouteLocale::class,
'The "locale" route attribute is not supported on route "form_class_route_locale" in "Drupal\\Tests\\Core\\Routing\\FormClassRouteLocale"',
TRUE,
],
'form_class: localized_paths' => [
FormClassRouteLocalizedPaths::class,
'The "path" route attribute does not support arrays on route "form_class_route_localized_paths" in "Drupal\\Tests\\Core\\Routing\\FormClassRouteLocalizedPaths"',
TRUE,
],
'form_class: condition' => [
FormClassRouteCondition::class,
'The "condition" route attribute is not supported on route "form_class_route_condition" in "Drupal\\Tests\\Core\\Routing\\FormClassRouteCondition"',
TRUE,
],
];
}
}
Members
| Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overrides |
|---|---|---|---|---|---|
| DrupalTestCaseTrait::$root | protected | property | The Drupal root directory. | ||
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | 1 | |
| DrupalTestCaseTrait::getDrupalRoot | Deprecated | protected static | function | Returns the Drupal root directory. | 1 |
| DrupalTestCaseTrait::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | ||
| DrupalTestCaseTrait::setUpRoot | final protected | function | Ensure that the $root property is set initially. | ||
| 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::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::setUp | protected | function | 361 | ||
| 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.