Version 1
[yaffs-website] / web / core / modules / block_content / tests / src / Kernel / Migrate / d7 / MigrateCustomBlockTest.php
diff --git a/web/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php b/web/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php
new file mode 100644 (file)
index 0000000..706a7cc
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+namespace Drupal\Tests\block_content\Kernel\Migrate\d7;
+
+use Drupal\block_content\BlockContentInterface;
+use Drupal\block_content\Entity\BlockContent;
+use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
+
+/**
+ * Tests migration of custom blocks.
+ *
+ * @group block_content
+ */
+class MigrateCustomBlockTest extends MigrateDrupal7TestBase {
+
+  public static $modules = [
+    'block_content',
+    'filter',
+    'text',
+  ];
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+    $this->installConfig(static::$modules);
+    $this->installEntitySchema('block_content');
+
+    $this->executeMigrations([
+      'd7_filter_format',
+      'block_content_type',
+      'block_content_body_field',
+      'd7_custom_block',
+    ]);
+  }
+
+  /**
+   * Tests migration of custom blocks from Drupal 7 to Drupal 8.
+   */
+  public function testCustomBlockMigration() {
+    $block = BlockContent::load(1);
+    $this->assertTrue($block instanceof BlockContentInterface);
+    /** @var \Drupal\block_content\BlockContentInterface $block */
+    $this->assertIdentical('Limerick', $block->label());
+
+    $expected_body = "A fellow jumped off a high wall\r\nAnd had a most terrible fall\r\nHe went back to bed\r\nWith a bump on his head\r\nThat's why you don't jump off a wall";
+    $this->assertIdentical($expected_body, $block->body->value);
+    $this->assertIdentical('filtered_html', $block->body->format);
+  }
+
+}