function InstallUninstallTest::preUninstallForum

Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php \Drupal\Tests\system\Functional\Module\InstallUninstallTest::preUninstallForum()

Deletes forum taxonomy terms, so Forum can be uninstalled.

1 call to InstallUninstallTest::preUninstallForum()
InstallUninstallTest::testInstallUninstall in core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php
Tests that a fixed set of modules can be installed and uninstalled.

File

core/modules/system/tests/src/Functional/Module/InstallUninstallTest.php, line 419

Class

InstallUninstallTest
Install/uninstall core module and confirm table creation/deletion.

Namespace

Drupal\Tests\system\Functional\Module

Code

protected function preUninstallForum() {
  // There only should be a 'General discussion' term in the 'forums'
  // vocabulary, but just delete any terms there in case the name changes.
  $query = \Drupal::entityQuery('taxonomy_term')->accessCheck(FALSE);
  $query->condition('vid', 'forums');
  $ids = $query->execute();
  $storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
  $terms = $storage->loadMultiple($ids);
  $storage->delete($terms);
}

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