You are here

public function InstallUninstallTest::testUninstall in Lightning Media 8.3

Tests module uninstall.

File

modules/lightning_media_slideshow/tests/src/Functional/InstallUninstallTest.php, line 93

Class

InstallUninstallTest
Tests install/uninstall operations of Media Slideshow.

Namespace

Drupal\Tests\lightning_media_slideshow\Functional

Code

public function testUninstall() {

  // No slideshow blocks exist yet, so validation should succeed.
  $problems = $this->moduleInstaller
    ->validateUninstall([
    'lightning_media_slideshow',
  ]);
  $this
    ->assertEmpty($problems);

  // Validation should fail if a slideshow exists.
  $slideshow_block = BlockContent::create([
    'type' => 'media_slideshow',
    'name' => $this
      ->randomString(),
  ]);
  $slideshow_block
    ->save();
  $problems = $this->moduleInstaller
    ->validateUninstall([
    'lightning_media_slideshow',
  ]);
  $this
    ->assertEquals([
    'To uninstall Media Slideshow, you must delete all slideshow blocks first.',
  ], $problems['lightning_media_slideshow']);

  // Validation should succeed once the slideshow is deleted.
  $slideshow_block
    ->delete();
  $problems = $this->moduleInstaller
    ->validateUninstall([
    'lightning_media_slideshow',
  ]);
  $this
    ->assertEmpty($problems);
  $module_data = $this->container
    ->get('extension.list.module')
    ->reset()
    ->get('lightning_media_slideshow');
  $this
    ->assertArrayNotHasKey('required', $module_data->info);
}