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