InstallProfileDependenciesTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 $profile = 'testing_install_profile_dependencies';
  15. /**
  16. * Tests that an install profile can require modules.
  17. */
  18. public function testUninstallingModules() {
  19. $user = $this->drupalCreateUser(['administer modules']);
  20. $this->drupalLogin($user);
  21. $this->drupalGet('admin/modules/uninstall');
  22. $this->assertSession()->fieldDisabled('uninstall[dblog]');
  23. $this->getSession()->getPage()->checkField('uninstall[ban]');
  24. $this->click('#edit-submit');
  25. // Click the confirm button.
  26. $this->click('#edit-submit');
  27. $this->assertSession()->responseContains('The selected modules have been uninstalled.');
  28. // We've uninstalled a module therefore we need to rebuild the container in
  29. // the test runner.
  30. $this->rebuildContainer();
  31. $this->assertFalse($this->container->get('module_handler')->moduleExists('ban'));
  32. try {
  33. $this->container->get('module_installer')->uninstall(['dblog']);
  34. $this->fail('Uninstalled dblog module.');
  35. }
  36. catch (ModuleUninstallValidatorException $e) {
  37. $this->assertContains('The Testing install profile dependencies module is required', $e->getMessage());
  38. }
  39. }
  40. }