Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / book / tests / src / Kernel / Migrate / d7 / MigrateBookTest.php
1 <?php
2
3 namespace Drupal\Tests\book\Kernel\Migrate\d7;
4
5 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
6 use Drupal\node\Entity\Node;
7
8 /**
9  * Tests migration of book structures from Drupal 7.
10  *
11  * @group migrate_drupal_7
12  */
13 class MigrateBookTest extends MigrateDrupal7TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = [
19     'book',
20     'menu_ui',
21     'node',
22     'taxonomy',
23     'text',
24   ];
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function setUp() {
30     parent::setUp();
31     $this->installEntitySchema('node');
32     $this->installEntitySchema('taxonomy_term');
33     $this->installConfig(['node']);
34     $this->installSchema('book', ['book']);
35     $this->installSchema('node', ['node_access']);
36     $this->executeMigrations([
37       'd7_user_role',
38       'd7_user',
39       'd7_node_type',
40       'd7_node',
41       'd7_book',
42     ]);
43   }
44
45   /**
46    * Tests the Drupal 7 book structure to Drupal 8 migration.
47    */
48   public function testBook() {
49     $nodes = Node::loadMultiple([1, 2, 4, 6]);
50     $this->assertSame('8', $nodes[1]->book['bid']);
51     $this->assertSame('6', $nodes[1]->book['pid']);
52
53     $this->assertSame('4', $nodes[2]->book['bid']);
54     $this->assertSame('6', $nodes[2]->book['pid']);
55
56     $this->assertSame('4', $nodes[4]->book['bid']);
57     $this->assertSame('0', $nodes[4]->book['pid']);
58
59     $this->assertSame('4', $nodes[6]->book['bid']);
60     $this->assertSame('4', $nodes[6]->book['pid']);
61
62     $tree = \Drupal::service('book.manager')->bookTreeAllData(4);
63     $this->assertSame('4', $tree['49990 is - The thing about Firefly 4']['link']['nid']);
64     $this->assertSame('6', $tree['49990 is - The thing about Firefly 4']['below']['50000 Comments are closed :-( 6']['link']['nid']);
65     $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']);
66     $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']);
67   }
68
69 }