InstallProfileDependenciesTest.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Drupal\FunctionalTests\Installer;
  3. use Drupal\Core\Extension\ModuleUninstallValidatorException;
  4. use Drupal\Tests\BrowserTestBase;
  5. /**
  6. * Tests that an install profile can require modules.
  7. *
  8. * @group Installer
  9. */
  10. class InstallProfileDependenciesTest extends BrowserTestBase {
  11. /**
  12. * {@inheritdoc}
  13. */
  14. protected $defaultTheme = 'stark';
  15. /**
  16. * {@inheritdoc}
  17. */
  18. protected $profile = 'testing_install_profile_dependencies';
  19. /**
  20. * Tests that an install profile can require modules.
  21. */
  22. public function testUninstallingModules() {
  23. $user = $this->drupalCreateUser(['administer modules']);
  24. $this->drupalLogin($user);
  25. $this->drupalGet('admin/modules/uninstall');
  26. $this->assertSession()->fieldDisabled('uninstall[dblog]');
  27. $this->getSession()->getPage()->checkField('uninstall[ban]');
  28. $this->click('#edit-submit');
  29. // Click the confirm button.
  30. $this->click('#edit-submit');
  31. $this->assertSession()->responseContains('The selected modules have been uninstalled.');
  32. // We've uninstalled a module therefore we need to rebuild the container in
  33. // the test runner.
  34. $this->rebuildContainer();
  35. $this->assertFalse($this->container->get('module_handler')->moduleExists('ban'));
  36. try {
  37. $this->container->get('module_installer')->uninstall(['dblog']);
  38. $this->fail('Uninstalled dblog module.');
  39. }
  40. catch (ModuleUninstallValidatorException $e) {
  41. $this->assertStringContainsString('The Testing install profile dependencies module is required', $e->getMessage());
  42. }
  43. }
  44. }