function BookInstallTest::testBookInstallWithPreexistingContentType

Same name in other branches
  1. 8.9.x core/modules/book/tests/src/Kernel/BookInstallTest.php \Drupal\Tests\book\Kernel\BookInstallTest::testBookInstallWithPreexistingContentType()
  2. 10 core/modules/book/tests/src/Kernel/BookInstallTest.php \Drupal\Tests\book\Kernel\BookInstallTest::testBookInstallWithPreexistingContentType()
  3. 11.x core/modules/book/tests/src/Kernel/BookInstallTest.php \Drupal\Tests\book\Kernel\BookInstallTest::testBookInstallWithPreexistingContentType()

Tests Book install with pre-existing content type.

Tests that Book module can be installed if content type with machine name 'book' already exists.

File

core/modules/book/tests/src/Kernel/BookInstallTest.php, line 29

Class

BookInstallTest
Test installation of Book module.

Namespace

Drupal\Tests\book\Kernel

Code

public function testBookInstallWithPreexistingContentType() {
    // Create a 'book' content type.
    NodeType::create([
        'type' => 'book',
    ])->save();
    // Install the Book module. Using the module installer service ensures that
    // all the install rituals, including default and optional configuration
    // import, are performed.
    $status = $this->container
        ->get('module_installer')
        ->install([
        'book',
    ]);
    $this->assertTrue($status, 'Book module installed successfully');
}

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