You are here

public function SimplenewsUninstallTest::testUninstall in Simplenews 8.2

Same name and namespace in other branches
  1. 3.x tests/src/Functional/SimplenewsUninstallTest.php \Drupal\Tests\simplenews\Functional\SimplenewsUninstallTest::testUninstall()

Tests that Simplenews module can be uninstalled.

File

tests/src/Functional/SimplenewsUninstallTest.php, line 36

Class

SimplenewsUninstallTest
Tests that Simplenews module can be uninstalled.

Namespace

Drupal\Tests\simplenews\Functional

Code

public function testUninstall() {

  // Add a newsletter issue.
  $this
    ->drupalCreateNode([
    'type' => 'simplenews_issue',
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();

  // Delete Simplenews data.
  $this
    ->drupalPostForm('admin/config/services/simplenews/settings/uninstall', [], t('Delete Simplenews data'));
  $this
    ->assertText(t('Simplenews data has been deleted.'));

  // Uninstall the module.
  $this
    ->drupalPostForm('admin/modules/uninstall', [
    'uninstall[simplenews]' => TRUE,
  ], t('Uninstall'));
  $this
    ->drupalPostForm(NULL, [], t('Uninstall'));
  $this
    ->assertText(t('The selected modules have been uninstalled.'));
  $this
    ->assertNoText(t('Simplenews'));

  // Make sure that the module can be installed again.
  $this
    ->drupalPostForm('admin/modules', [
    'modules[simplenews][enable]' => TRUE,
  ], t('Install'));
  $this
    ->assertText('Module Simplenews has been enabled.');
}