DependencyTest.php

Same filename in this branch
  1. 11.x core/modules/system/tests/src/Functional/Module/DependencyTest.php
  2. 11.x core/tests/Drupal/Tests/Core/Extension/DependencyTest.php
Same filename in other branches
  1. 9 core/modules/system/tests/src/Functional/Module/DependencyTest.php
  2. 9 core/tests/Drupal/Tests/Core/Extension/DependencyTest.php
  3. 8.9.x core/modules/system/tests/src/Functional/Module/DependencyTest.php
  4. 8.9.x core/tests/Drupal/Tests/Core/Extension/DependencyTest.php
  5. 10 core/modules/forum/tests/src/Functional/Module/DependencyTest.php
  6. 10 core/modules/system/tests/src/Functional/Module/DependencyTest.php
  7. 10 core/tests/Drupal/Tests/Core/Extension/DependencyTest.php

Namespace

Drupal\Tests\forum\Functional\Module

File

core/modules/forum/tests/src/Functional/Module/DependencyTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\forum\Functional\Module;

use Drupal\Tests\system\Functional\Module\ModuleTestBase;

/**
 * Enable module without dependency enabled.
 *
 * @group form
 * @group legacy
 */
class DependencyTest extends ModuleTestBase {
    
    /**
     * {@inheritdoc}
     */
    protected $defaultTheme = 'stark';
    
    /**
     * Tests attempting to uninstall a module that has installed dependents.
     */
    public function testUninstallDependents() {
        // Enable the forum module.
        $edit = [
            'modules[forum][enable]' => 'forum',
        ];
        $this->drupalGet('admin/modules');
        $this->submitForm($edit, 'Install');
        $this->submitForm([], 'Continue');
        $this->assertModules([
            'forum',
        ], TRUE);
        // Check that the comment module cannot be uninstalled.
        $this->drupalGet('admin/modules/uninstall');
        $this->assertSession()
            ->fieldDisabled('uninstall[comment]');
        // Delete any forum terms.
        $vid = $this->config('forum.settings')
            ->get('vocabulary');
        // Ensure taxonomy has been loaded into the test-runner after forum was
        // enabled.
        \Drupal::moduleHandler()->load('taxonomy');
        $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
        $terms = $storage->loadByProperties([
            'vid' => $vid,
        ]);
        $storage->delete($terms);
        // Uninstall the forum module, and check that taxonomy now can also be
        // uninstalled.
        $edit = [
            'uninstall[forum]' => 'forum',
        ];
        $this->drupalGet('admin/modules/uninstall');
        $this->submitForm($edit, 'Uninstall');
        $this->submitForm([], 'Uninstall');
        $this->assertSession()
            ->pageTextContains('The selected modules have been uninstalled.');
        // Uninstall comment module.
        $edit = [
            'uninstall[comment]' => 'comment',
        ];
        $this->drupalGet('admin/modules/uninstall');
        $this->submitForm($edit, 'Uninstall');
        $this->submitForm([], 'Uninstall');
        $this->assertSession()
            ->pageTextContains('The selected modules have been uninstalled.');
    }

}

Classes

Title Deprecated Summary
DependencyTest Enable module without dependency enabled.

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