You are here

public function NodeTypeExampleTest::testUninstallReinstall in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 node_type_example/tests/src/Functional/NodeTypeExampleTest.php \Drupal\Tests\node_type_example\Functional\NodeTypeExampleTest::testUninstallReinstall()

Verify that user can uninstall and then reinstall node_type_example.

File

modules/node_type_example/tests/src/Functional/NodeTypeExampleTest.php, line 167

Class

NodeTypeExampleTest
Test that our content types are successfully created.

Namespace

Drupal\Tests\node_type_example\Functional

Code

public function testUninstallReinstall() {
  $session = $this
    ->assertSession();

  // Uninstalling module.
  $module_installer = $this->container
    ->get('module_installer');
  $module_installer
    ->uninstall([
    'node_type_example',
  ]);
  $this
    ->drupalGet('examples/node-type-example');
  $session
    ->statusCodeEquals(404);

  // Re-installing module.
  $module_installer
    ->install([
    'node_type_example',
  ]);
  $this
    ->drupalGet('examples/node-type-example');
  $session
    ->statusCodeEquals(200);
}