function PrepareModulesEntityUninstallFormTest::testModuleEntityUninstallTitle

Same name in other branches
  1. 10 core/modules/system/tests/src/Kernel/Module/PrepareModulesEntityUninstallFormTest.php \Drupal\Tests\system\Kernel\Module\PrepareModulesEntityUninstallFormTest::testModuleEntityUninstallTitle()

Tests PrepareModulesEntityUninstallForm::formTitle.

File

core/modules/system/tests/src/Kernel/Module/PrepareModulesEntityUninstallFormTest.php, line 29

Class

PrepareModulesEntityUninstallFormTest
Tests PrepareModulesEntityUninstallForm.

Namespace

Drupal\Tests\system\Kernel\Module

Code

public function testModuleEntityUninstallTitle() : void {
    $this->setUpCurrentUser(permissions: [
        'administer modules',
    ]);
    
    /** @var \Drupal\Core\Controller\TitleResolverInterface $title_resolver */
    $title_resolver = \Drupal::service('title_resolver');
    \Drupal::service('router.builder')->rebuild();
    $request = Request::create('/admin/modules/uninstall/entity/user');
    // Simulate matching.
    $request->attributes
        ->set('entity_type_id', 'user');
    $route = \Drupal::service('router.route_provider')->getRouteByName('system.prepare_modules_entity_uninstall');
    $title = (string) $title_resolver->getTitle($request, $route);
    $this->assertEquals('Are you sure you want to delete all users?', $title);
    $not_an_entity_type = $this->randomMachineName();
    $request = Request::create('/admin/modules/uninstall/entity/' . $not_an_entity_type);
    // Simulate matching.
    $request->attributes
        ->set('entity_type_id', $not_an_entity_type);
    $this->expectException(PluginNotFoundException::class);
    (string) $title_resolver->getTitle($request, $route);
}

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