3 namespace Drupal\Tests\book\Kernel\Migrate\d7;
5 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
6 use Drupal\node\Entity\Node;
9 * Tests migration of book structures from Drupal 7.
11 * @group migrate_drupal_7
13 class MigrateBookTest extends MigrateDrupal7TestBase {
18 public static $modules = [
29 protected function 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([
46 * Tests the Drupal 7 book structure to Drupal 8 migration.
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']);
53 $this->assertSame('4', $nodes[2]->book['bid']);
54 $this->assertSame('6', $nodes[2]->book['pid']);
56 $this->assertSame('4', $nodes[4]->book['bid']);
57 $this->assertSame('0', $nodes[4]->book['pid']);
59 $this->assertSame('4', $nodes[6]->book['bid']);
60 $this->assertSame('4', $nodes[6]->book['pid']);
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']);