diff --git a/core/modules/book/tests/src/Kernel/Migrate/d7/MigrateBookTest.php b/core/modules/book/tests/src/Kernel/Migrate/d7/MigrateBookTest.php index 3a1cb03..8d5f65e 100644 --- a/core/modules/book/tests/src/Kernel/Migrate/d7/MigrateBookTest.php +++ b/core/modules/book/tests/src/Kernel/Migrate/d7/MigrateBookTest.php @@ -17,19 +17,9 @@ class MigrateBookTest extends MigrateDrupal7TestBase { */ public static $modules = [ 'book', - - 'content_translation', - 'comment', - 'datetime', - 'filter', - 'image', - 'language', - 'link', - + 'menu_ui', 'node', - 'taxonomy', - 'telephone', 'text', ]; @@ -39,25 +29,16 @@ class MigrateBookTest extends MigrateDrupal7TestBase { protected function setUp() { parent::setUp(); $this->installEntitySchema('node'); - $this->installEntitySchema('comment'); $this->installEntitySchema('taxonomy_term'); - $this->installEntitySchema('file'); - $this->installConfig(static::$modules); + $this->installConfig(['node']); $this->installSchema('book', ['book']); $this->installSchema('node', ['node_access']); -// $this->migrateContent(); $this->executeMigrations([ 'd7_user_role', 'd7_user', 'd7_node_type', - - 'd7_language_content_settings', - 'd7_comment_type', - 'd7_taxonomy_vocabulary', - - 'd7_field', - 'd7_field_instance', 'd7_node', + 'd7_menu_links', 'd7_book' ]); } @@ -66,30 +47,24 @@ protected function setUp() { * Tests the Drupal 7 book structure to Drupal 8 migration. */ public function testBook() { - // @todo Write the tests for D7. -// $nodes = Node::loadMultiple([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([], $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 6 6']['below']); -// $this->assertIdentical([], $tree['49990 Node 4 4']['below']['50000 Node 5 5']['below']['50000 Node 7 7']['below']); + $nodes = Node::loadMultiple([1, 2, 4, 6]); + $this->assertSame('8', $nodes[1]->book['bid']); + $this->assertSame('6', $nodes[1]->book['pid']); + + $this->assertSame('4', $nodes[2]->book['bid']); + $this->assertSame('6', $nodes[2]->book['pid']); + + $this->assertSame('4', $nodes[4]->book['bid']); + $this->assertSame('0', $nodes[4]->book['pid']); + + $this->assertSame('4', $nodes[6]->book['bid']); + $this->assertSame('4', $nodes[6]->book['pid']); + + $tree = \Drupal::service('book.manager')->bookTreeAllData(4); + $this->assertSame('4', $tree['49990 is - The thing about Firefly 4']['link']['nid']); + $this->assertSame('6', $tree['49990 is - The thing about Firefly 4']['below']['50000 Comments are closed :-( 6']['link']['nid']); + $this->assertSame('2', $tree['49990 is - The thing about Firefly 4']['below']['50000 Comments are closed :-( 6']['below']['50000 The thing about Deep Space 9 2']['link']['nid']); + $this->assertSame([], $tree['49990 is - The thing about Firefly 4']['below']['50000 Comments are closed :-( 6']['below']['50000 The thing about Deep Space 9 2']['below']); } } diff --git a/core/modules/migrate_drupal/tests/fixtures/drupal7.php b/core/modules/migrate_drupal/tests/fixtures/drupal7.php index 410601f..18fa41f 100644 --- a/core/modules/migrate_drupal/tests/fixtures/drupal7.php +++ b/core/modules/migrate_drupal/tests/fixtures/drupal7.php @@ -1906,6 +1906,34 @@ 'mysql_character_set' => 'utf8', )); +$connection->insert('book') + ->fields(array( + 'mlid', + 'nid', + 'bid', + )) + ->values(array( + 'mlid' => '480', + 'nid' => '4', + 'bid' => '4', + )) + ->values(array( + 'mlid' => '481', + 'nid' => '6', + 'bid' => '4', + )) + ->values(array( + 'mlid' => '482', + 'nid' => '2', + 'bid' => '4', + )) + ->values(array( + 'mlid' => '483', + 'nid' => '1', + 'bid' => '8', + )) + ->execute(); + $connection->schema()->createTable('cache', array( 'fields' => array( 'cid' => array( @@ -22571,6 +22599,114 @@ 'p9' => '0', 'updated' => '0', )) + ->values(array( + 'menu_name' => 'book-toc-1', + 'mlid' => '480', + 'plid' => '0', + 'link_path' => 'node/4', + 'router_path' => 'node/%', + 'link_title' => 'Test top book title', + 'options' => 'a:0:{}', + 'module' => 'book', + 'hidden' => '0', + 'external' => '0', + 'has_children' => '1', + 'expanded' => '0', + 'weight' => '-10', + 'depth' => '1', + 'customized' => '0', + 'p1' => '480', + 'p2' => '0', + 'p3' => '0', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + )) + ->values(array( + 'menu_name' => 'book-toc-1', + 'mlid' => '481', + 'plid' => '480', + 'link_path' => 'node/6', + 'router_path' => 'node/%', + 'link_title' => 'Test book title child 1', + 'options' => 'a:0:{}', + 'module' => 'book', + 'hidden' => '0', + 'external' => '0', + 'has_children' => '1', + 'expanded' => '0', + 'weight' => '0', + 'depth' => '2', + 'customized' => '0', + 'p1' => '480', + 'p2' => '481', + 'p3' => '0', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + )) + ->values(array( + 'menu_name' => 'book-toc-1', + 'mlid' => '482', + 'plid' => '481', + 'link_path' => 'node/2', + 'router_path' => 'node/%', + 'link_title' => 'Test book title child 1.1', + 'options' => 'a:0:{}', + 'module' => 'book', + 'hidden' => '0', + 'external' => '0', + 'has_children' => '0', + 'expanded' => '0', + 'weight' => '0', + 'depth' => '3', + 'customized' => '0', + 'p1' => '480', + 'p2' => '481', + 'p3' => '482', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + )) + ->values(array( + 'menu_name' => 'book-toc-2', + 'mlid' => '483', + 'plid' => '481', + 'link_path' => 'node/1', + 'router_path' => 'node/%', + 'link_title' => 'Test book title 2', + 'options' => 'a:0:{}', + 'module' => 'book', + 'hidden' => '0', + 'external' => '0', + 'has_children' => '0', + 'expanded' => '0', + 'weight' => '0', + 'depth' => '3', + 'customized' => '0', + 'p1' => '480', + 'p2' => '481', + 'p3' => '483', + 'p4' => '0', + 'p5' => '0', + 'p6' => '0', + 'p7' => '0', + 'p8' => '0', + 'p9' => '0', + 'updated' => '0', + )) ->execute(); $connection->schema()->createTable('menu_router', array(