Version 1
[yaffs-website] / web / core / modules / book / tests / src / Functional / BookInstallTest.php
1 <?php
2
3 namespace Drupal\Tests\book\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6 use Drupal\Core\Config\PreExistingConfigException;
7
8 /**
9  * Test installation of Book module.
10  *
11  * @group book
12  */
13 class BookInstallTest extends BrowserTestBase {
14
15   /**
16    * Modules to install.
17    *
18    * @var array
19    */
20   public static $modules = ['node'];
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function setUp() {
26     parent::setUp();
27   }
28
29   /**
30    * Test Book install with pre-existing content type.
31    *
32    * Tests that Book module can be installed if content type with machine name
33    * 'book' already exists.
34    */
35   public function testBookInstallWithPreexistingContentType() {
36     // Create a 'book' content type.
37     $this->drupalCreateContentType(['type' => 'book']);
38
39     // Install the Book module.
40     try {
41       $this->container->get('module_installer')->install(['book']);
42     }
43     catch (PreExistingConfigException $e) {
44       $this->fail("Expected exception thrown trying to install Book module: " . $e->getMessage());
45     }
46   }
47
48 }