class ThirdPartyUninstallTest

Tests proper removal of third-party settings from views.

@group views

Hierarchy

Expanded class hierarchy of ThirdPartyUninstallTest

File

core/modules/views/tests/src/Kernel/ThirdPartyUninstallTest.php, line 14

Namespace

Drupal\Tests\views\Kernel
View source
class ThirdPartyUninstallTest extends ViewsKernelTestBase {
  
  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'node',
    'views_third_party_settings_test',
  ];
  
  /**
   * Views used by this test.
   *
   * @var array
   */
  public static $testViews = [
    'test_third_party_uninstall',
  ];
  
  /**
   * {@inheritdoc}
   */
  protected function setUp($import_test_views = TRUE) : void {
    parent::setUp($import_test_views);
    $this->installEntitySchema('user');
    $this->installSchema('user', [
      'users_data',
    ]);
  }
  
  /**
   * Tests removing third-party settings when a provider module is uninstalled.
   */
  public function testThirdPartyUninstall() : void {
    $view = View::load('test_third_party_uninstall');
    $this->assertNotEmpty($view);
    $this->assertContains('views_third_party_settings_test', $view->getDependencies()['module']);
    $this->assertTrue($view->getThirdPartySetting('views_third_party_settings_test', 'example_setting'));
    \Drupal::service('module_installer')->uninstall([
      'views_third_party_settings_test',
    ]);
    $view = View::load('test_third_party_uninstall');
    $this->assertNotEmpty($view);
    $this->assertNotContains('views_third_party_settings_test', $view->getDependencies()['module']);
    $this->assertNull($view->getThirdPartySetting('views_third_party_settings_test', 'example_setting'));
  }

}

Members

Title Sort descending Modifiers Object type Summary
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
ExpectDeprecationTrait::expectDeprecation public function Adds an expected deprecation.
ExpectDeprecationTrait::setUpErrorHandler public function Sets up the test error handler.
ExpectDeprecationTrait::tearDownErrorHandler public function Tears down the test error handler.
ExtensionListTestTrait::getModulePath protected function Gets the path for the specified module.
ExtensionListTestTrait::getThemePath protected function Gets the path for the specified theme.
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.
ThirdPartyUninstallTest::$modules protected static property Modules to install.
ThirdPartyUninstallTest::$testViews public static property Views used by this test.
ThirdPartyUninstallTest::setUp protected function
ThirdPartyUninstallTest::testThirdPartyUninstall public function Tests removing third-party settings when a provider module is uninstalled.

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