diff --git a/core/modules/book/migrations/d6_book.yml b/core/modules/book/migrations/d6_book.yml index 94d7a8f..3036e1f 100644 --- a/core/modules/book/migrations/d6_book.yml +++ b/core/modules/book/migrations/d6_book.yml @@ -3,7 +3,7 @@ label: Books migration_tags: - Drupal 6 source: - plugin: d6_book + plugin: book process: nid: nid 'book/bid': bid @@ -21,3 +21,4 @@ destination: migration_dependencies: required: - d6_node + - d6_menu_links diff --git a/core/modules/book/migrations/d7_book.yml b/core/modules/book/migrations/d7_book.yml new file mode 100644 index 0000000..e46df60 --- /dev/null +++ b/core/modules/book/migrations/d7_book.yml @@ -0,0 +1,24 @@ +id: d7_book +label: Books +migration_tags: + - Drupal 7 +source: + plugin: book +process: + nid: nid + 'book/bid': bid + 'book/weight': weight + 'book/pid': + - + plugin: skip_on_empty + method: process + source: plid + - + plugin: migration_lookup + migration: d7_book +destination: + plugin: book +migration_dependencies: + required: + - d7_node + - d7_menu_links diff --git a/core/modules/book/migrations/d7_book_settings.yml b/core/modules/book/migrations/d7_book_settings.yml new file mode 100644 index 0000000..b0c4fa9 --- /dev/null +++ b/core/modules/book/migrations/d7_book_settings.yml @@ -0,0 +1,18 @@ +id: d7_book_settings +label: Drupal 7 book configuration +migration_tags: + - Drupal 7 +source: + plugin: variable + variables: + - book_child_type + - book_block_mode + - book_allowed_types + source_module: book +process: + child_type: book_child_type + 'block/navigation/mode': book_block_mode + allowed_types: book_allowed_types +destination: + plugin: config + config_name: book.settings diff --git a/core/modules/book/src/Plugin/migrate/source/d6/Book.php b/core/modules/book/src/Plugin/migrate/source/Book.php similarity index 95% rename from core/modules/book/src/Plugin/migrate/source/d6/Book.php rename to core/modules/book/src/Plugin/migrate/source/Book.php index 87ae972..76d9b6a 100644 --- a/core/modules/book/src/Plugin/migrate/source/d6/Book.php +++ b/core/modules/book/src/Plugin/migrate/source/Book.php @@ -1,14 +1,14 @@ executeMigration('d7_book_settings'); + } + + /** + * Tests migration of book variables to book.settings.yml. + */ + public function testBookSettings() { + $config = $this->config('book.settings'); + $this->assertSame('book', $config->get('child_type')); + $this->assertSame('all pages', $config->get('block.navigation.mode')); + $this->assertSame(['book'], $config->get('allowed_types')); + $this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get()); + } + +} diff --git a/core/modules/book/tests/src/Kernel/Migrate/d7/MigrateBookTest.php b/core/modules/book/tests/src/Kernel/Migrate/d7/MigrateBookTest.php new file mode 100644 index 0000000..cc0f7bb --- /dev/null +++ b/core/modules/book/tests/src/Kernel/Migrate/d7/MigrateBookTest.php @@ -0,0 +1,70 @@ +installEntitySchema('node'); + $this->installEntitySchema('taxonomy_term'); + $this->installConfig(['node']); + $this->installSchema('book', ['book']); + $this->installSchema('node', ['node_access']); + $this->executeMigrations([ + 'd7_user_role', + 'd7_user', + 'd7_node_type', + 'd7_node', + 'd7_menu_links', + 'd7_book' + ]); + } + + /** + * Tests the Drupal 7 book structure to Drupal 8 migration. + */ + public function testBook() { + $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/book/tests/src/Kernel/Plugin/migrate/source/d6/BookTest.php b/core/modules/book/tests/src/Kernel/Plugin/migrate/source/BookTest.php similarity index 93% rename from core/modules/book/tests/src/Kernel/Plugin/migrate/source/d6/BookTest.php rename to core/modules/book/tests/src/Kernel/Plugin/migrate/source/BookTest.php index feece1f..0d423db 100644 --- a/core/modules/book/tests/src/Kernel/Plugin/migrate/source/d6/BookTest.php +++ b/core/modules/book/tests/src/Kernel/Plugin/migrate/source/BookTest.php @@ -1,11 +1,11 @@ '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( @@ -22957,6 +22985,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( @@ -46319,6 +46455,10 @@ 'value' => 'a:1:{i:0;s:4:"book";}', )) ->values(array( + 'name' => 'book_block_mode', + 'value' => 's:9:"all pages";', +)) +->values(array( 'name' => 'book_child_type', 'value' => 's:4:"book";', )) diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php index b8ea52b..be048f9 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php @@ -34,6 +34,7 @@ protected function getAvailablePaths() { return [ 'aggregator', 'block', + 'book', 'comment', 'contact', 'date', @@ -115,7 +116,6 @@ protected function getAvailablePaths() { */ protected function getMissingPaths() { return [ - 'book', 'color', 'rdf', 'views', diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php index 2b31a79..63ec743 100644 --- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php +++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7Test.php @@ -103,6 +103,7 @@ protected function getAvailablePaths() { return [ 'aggregator', 'block', + 'book', 'comment', 'contact', 'date', @@ -154,7 +155,6 @@ protected function getAvailablePaths() { */ protected function getMissingPaths() { return [ - 'book', 'color', 'rdf', // These modules are in the missing path list because they are installed diff --git a/patches/interdiff-56-58.txt b/patches/interdiff-56-58.txt new file mode 100644 index 0000000..0416e00 --- /dev/null +++ b/patches/interdiff-56-58.txt @@ -0,0 +1,20 @@ +diff --git a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php +index b8ea52b..be048f9 100644 +--- a/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php ++++ b/core/modules/migrate_drupal_ui/tests/src/Functional/d7/MigrateUpgrade7ReviewPageTest.php +@@ -34,6 +34,7 @@ protected function getAvailablePaths() { + return [ + 'aggregator', + 'block', ++ 'book', + 'comment', + 'contact', + 'date', +@@ -115,7 +116,6 @@ protected function getAvailablePaths() { + */ + protected function getMissingPaths() { + return [ +- 'book', + 'color', + 'rdf', + 'views',