Unverified Commit 46d96a40 authored by alexpott's avatar alexpott

Issue #3046694 by vadim.hirbu, claudiu.cristea, Lendude, catch: Convert...

Issue #3046694 by vadim.hirbu, claudiu.cristea, Lendude, catch: Convert BookInstallTest into a Kernel test
parent 9c0d6271
<?php
namespace Drupal\Tests\book\Functional;
namespace Drupal\Tests\book\Kernel;
use Drupal\Tests\BrowserTestBase;
use Drupal\Core\Config\PreExistingConfigException;
use Drupal\KernelTests\KernelTestBase;
use Drupal\node\Entity\NodeType;
/**
* Test installation of Book module.
*
* @group book
*/
class BookInstallTest extends BrowserTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = ['node'];
class BookInstallTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
}
protected static $modules = [
'node',
'system',
];
/**
* Test Book install with pre-existing content type.
......@@ -34,15 +28,12 @@ protected function setUp() {
*/
public function testBookInstallWithPreexistingContentType() {
// Create a 'book' content type.
$this->drupalCreateContentType(['type' => 'book']);
// Install the Book module.
try {
$this->container->get('module_installer')->install(['book']);
}
catch (PreExistingConfigException $e) {
$this->fail("Expected exception thrown trying to install Book module: " . $e->getMessage());
}
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');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment