Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
94
core/modules/book/tests/src/Kernel/BookUninstallTest.php
Normal file
94
core/modules/book/tests/src/Kernel/BookUninstallTest.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\book\Kernel;
|
||||
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests that the Book module cannot be uninstalled if books exist.
|
||||
*
|
||||
* @group book
|
||||
*/
|
||||
class BookUninstallTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['system', 'user', 'field', 'filter', 'text', 'node', 'book'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installSchema('book', array('book'));
|
||||
$this->installSchema('node', array('node_access'));
|
||||
$this->installConfig(array('node', 'book', 'field'));
|
||||
// For uninstall to work.
|
||||
$this->installSchema('user', array('users_data'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the book_system_info_alter() method.
|
||||
*/
|
||||
public function testBookUninstall() {
|
||||
// No nodes exist.
|
||||
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
|
||||
$this->assertEqual([], $validation_reasons, 'The book module is not required.');
|
||||
|
||||
$content_type = NodeType::create(array(
|
||||
'type' => $this->randomMachineName(),
|
||||
'name' => $this->randomString(),
|
||||
));
|
||||
$content_type->save();
|
||||
$book_config = $this->config('book.settings');
|
||||
$allowed_types = $book_config->get('allowed_types');
|
||||
$allowed_types[] = $content_type->id();
|
||||
$book_config->set('allowed_types', $allowed_types)->save();
|
||||
|
||||
$node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
|
||||
$node->book['bid'] = 'new';
|
||||
$node->save();
|
||||
|
||||
// One node in a book but not of type book.
|
||||
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
|
||||
$this->assertEqual(['To uninstall Book, delete all content that is part of a book'], $validation_reasons['book']);
|
||||
|
||||
$book_node = Node::create(array('title' => $this->randomString(), 'type' => 'book'));
|
||||
$book_node->book['bid'] = FALSE;
|
||||
$book_node->save();
|
||||
|
||||
// Two nodes, one in a book but not of type book and one book node (which is
|
||||
// not in a book).
|
||||
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
|
||||
$this->assertEqual(['To uninstall Book, delete all content that is part of a book'], $validation_reasons['book']);
|
||||
|
||||
$node->delete();
|
||||
// One node of type book but not actually part of a book.
|
||||
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
|
||||
$this->assertEqual(['To uninstall Book, delete all content that has the Book content type'], $validation_reasons['book']);
|
||||
|
||||
$book_node->delete();
|
||||
// No nodes exist therefore the book module is not required.
|
||||
$module_data = _system_rebuild_module_data();
|
||||
$this->assertFalse(isset($module_data['book']->info['required']), 'The book module is not required.');
|
||||
|
||||
$node = Node::create(array('title' => $this->randomString(), 'type' => $content_type->id()));
|
||||
$node->save();
|
||||
// One node exists but is not part of a book therefore the book module is
|
||||
// not required.
|
||||
$validation_reasons = \Drupal::service('module_installer')->validateUninstall(['book']);
|
||||
$this->assertEqual([], $validation_reasons, 'The book module is not required.');
|
||||
|
||||
// Uninstall the Book module and check the node type is deleted.
|
||||
\Drupal::service('module_installer')->uninstall(array('book'));
|
||||
$this->assertNull(NodeType::load('book'), "The book node type does not exist.");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\book\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to book.settings.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateBookConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['book'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_book_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of book variables to book.settings.yml.
|
||||
*/
|
||||
public function testBookSettings() {
|
||||
$config = $this->config('book.settings');
|
||||
$this->assertIdentical('book', $config->get('child_type'));
|
||||
$this->assertIdentical('all pages', $config->get('block.navigation.mode'));
|
||||
$this->assertIdentical(array('book'), $config->get('allowed_types'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\book\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
* Upgrade book structure.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateBookTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['book'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('book', ['book']);
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->migrateContent();
|
||||
$this->executeMigrations(['d6_node', 'd6_book']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the Drupal 6 book structure to Drupal 8 migration.
|
||||
*/
|
||||
public function testBook() {
|
||||
$nodes = Node::loadMultiple(array(4, 5, 6, 7, 8));
|
||||
$this->assertIdentical('4', $nodes[4]->book['bid']);
|
||||
$this->assertIdentical('0', $nodes[4]->book['pid']);
|
||||
|
||||
$this->assertIdentical('4', $nodes[5]->book['bid']);
|
||||
$this->assertIdentical('4', $nodes[5]->book['pid']);
|
||||
|
||||
$this->assertIdentical('4', $nodes[6]->book['bid']);
|
||||
$this->assertIdentical('5', $nodes[6]->book['pid']);
|
||||
|
||||
$this->assertIdentical('4', $nodes[7]->book['bid']);
|
||||
$this->assertIdentical('5', $nodes[7]->book['pid']);
|
||||
|
||||
$this->assertIdentical('8', $nodes[8]->book['bid']);
|
||||
$this->assertIdentical('0', $nodes[8]->book['pid']);
|
||||
|
||||
$tree = \Drupal::service('book.manager')->bookTreeAllData(4);
|
||||
$this->assertIdentical('4', $tree['49990 Node 4 4']['link']['nid']);
|
||||
$this->assertIdentical('5', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['link']['nid']);
|
||||
$this->assertIdentical('6', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['link']['nid']);
|
||||
$this->assertIdentical('7', $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['link']['nid']);
|
||||
$this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']);
|
||||
$this->assertIdentical(array(), $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\book\Unit\BookManagerTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\book\Unit;
|
||||
|
||||
use Drupal\book\BookManager;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\book\Unit\BookUninstallValidatorTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\book\Unit;
|
||||
|
||||
use Drupal\simpletest\AssertHelperTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\book\Unit\Menu\BookLocalTasksTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\book\Unit\Menu;
|
||||
|
||||
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\book\Unit\Plugin\migrate\source\d6\BookTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\book\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\book\Plugin\migrate\source\d6\Book;
|
||||
|
|
Reference in a new issue