public function EasyBreadcrumbBuilderTest::testGetTitleString in Easy Breadcrumb 2.x
Same name and namespace in other branches
- 8 tests/src/Kernel/EasyBreadcrumbBuilderTest.php \Drupal\Tests\easy_breadcrumb\Kernel\EasyBreadcrumbBuilderTest::testGetTitleString()
Tests getting title string from the various ways route titles can be set.
@dataProvider providerTestGetTitleString
Parameters
string $route_name: The route to test.
File
- tests/
src/ Kernel/ EasyBreadcrumbBuilderTest.php, line 83
Class
- EasyBreadcrumbBuilderTest
- Tests the easy breadcrumb builder.
Namespace
Drupal\Tests\easy_breadcrumb\KernelCode
public function testGetTitleString($route_name) {
$url = Url::fromRoute($route_name);
$request_context = new RequestContext();
$breadcrumb_builder = new EasyBreadcrumbBuilder($request_context, \Drupal::service('access_manager'), \Drupal::service('router'), \Drupal::service('request_stack'), \Drupal::service('path_processor_manager'), \Drupal::service('config.factory'), \Drupal::service('title_resolver'), \Drupal::service('current_user'), \Drupal::service('path.current'), \Drupal::service('plugin.manager.menu.link'), \Drupal::service('language_manager'), \Drupal::service('entity_type.manager'), \Drupal::service('entity.repository'), \Drupal::service('logger.factory'), \Drupal::service('messenger'), \Drupal::service('module_handler'));
$request = Request::create($url
->getInternalPath());
$router = \Drupal::service('router.no_access_checks');
$route_match = new RouteMatch($route_name, $router
->match($url
->getInternalPath())['_route_object']);
$result = $breadcrumb_builder
->getTitleString($request, $route_match, []);
$this
->assertIsString($result);
}