class PrepareModulesEntityUninstallFormTest

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Kernel/Module/PrepareModulesEntityUninstallFormTest.php \Drupal\Tests\system\Kernel\Module\PrepareModulesEntityUninstallFormTest

Tests PrepareModulesEntityUninstallForm.

@group Module

Hierarchy

Expanded class hierarchy of PrepareModulesEntityUninstallFormTest

File

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

Namespace

Drupal\Tests\system\Kernel\Module
View source
class PrepareModulesEntityUninstallFormTest extends KernelTestBase {
  use UserCreationTrait;
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'user',
    'system',
  ];
  
  /**
   * Tests PrepareModulesEntityUninstallForm::formTitle.
   */
  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);
  }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
ExtensionListTestTrait::getModulePath protected function Gets the path for the specified module.
ExtensionListTestTrait::getThemePath protected function Gets the path for the specified theme.
PrepareModulesEntityUninstallFormTest::$modules protected static property Modules to install.
PrepareModulesEntityUninstallFormTest::testModuleEntityUninstallTitle public function Tests PrepareModulesEntityUninstallForm::formTitle.
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.
RandomGeneratorTrait::randomStringValidate Deprecated public function Callback for random string validation.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
TestRequirementsTrait::checkModuleRequirements Deprecated private function Checks missing module requirements.
TestRequirementsTrait::checkRequirements Deprecated protected function Check module requirements for the Drupal use case.
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.

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