function CallableResolverTest::callableResolverExceptionHandlingTestCases
Same name in other branches
- 11.x core/tests/Drupal/Tests/Core/Utility/CallableResolverTest.php \Drupal\Tests\Core\Utility\CallableResolverTest::callableResolverExceptionHandlingTestCases()
Test cases for ::testCallbackResolverExceptionHandling.
File
-
core/
tests/ Drupal/ Tests/ Core/ Utility/ CallableResolverTest.php, line 132
Class
- CallableResolverTest
- @coversDefaultClass \Drupal\Core\Utility\CallableResolver @group Utility
Namespace
Drupal\Tests\Core\UtilityCode
public static function callableResolverExceptionHandlingTestCases() {
return [
'String function' => [
'not_a_callable',
\InvalidArgumentException::class,
'Class "not_a_callable" does not exist.',
],
'Array notation' => [
[
'not_a_callable',
'not_a_callable',
],
\InvalidArgumentException::class,
'The callable definition provided "[not_a_callable,not_a_callable]" is not a valid callable.',
],
'Missing method on class, array notation' => [
[
static::class,
'method_not_exists',
],
\InvalidArgumentException::class,
'The callable definition provided "[Drupal\\Tests\\Core\\Utility\\CallableResolverTest,method_not_exists]" is not a valid callable.',
],
'Missing method on class, static notation' => [
static::class . '::method_not_exists',
\InvalidArgumentException::class,
'The callable definition provided was invalid. Either class "Drupal\\Tests\\Core\\Utility\\CallableResolverTest" does not have a method "method_not_exists", or it is not callable.',
],
'Missing class, static notation' => [
'\\NotARealClass::method',
\InvalidArgumentException::class,
'Class "\\NotARealClass" does not exist.',
],
'No method, static notation' => [
NoMethodCallable::class . "::",
\InvalidArgumentException::class,
'The callable definition provided was invalid. Could not get class and method from definition "Drupal\\Tests\\Core\\Utility\\NoMethodCallable::".',
],
'Service not in container' => [
'bad_service:method',
\InvalidArgumentException::class,
'Class "bad_service" does not exist.',
],
'Invalid method on valid service' => [
'test_service:not_a_callable',
\InvalidArgumentException::class,
'The callable definition provided was invalid. Either class "Drupal\\Tests\\Core\\Utility\\CallableResolverTest" does not have a method "not_a_callable", or it is not callable.',
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.