Version 1
[yaffs-website] / web / core / modules / block_content / tests / src / Kernel / Migrate / d7 / MigrateCustomBlockTest.php
1 <?php
2
3 namespace Drupal\Tests\block_content\Kernel\Migrate\d7;
4
5 use Drupal\block_content\BlockContentInterface;
6 use Drupal\block_content\Entity\BlockContent;
7 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
8
9 /**
10  * Tests migration of custom blocks.
11  *
12  * @group block_content
13  */
14 class MigrateCustomBlockTest extends MigrateDrupal7TestBase {
15
16   public static $modules = [
17     'block_content',
18     'filter',
19     'text',
20   ];
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function setUp() {
26     parent::setUp();
27     $this->installConfig(static::$modules);
28     $this->installEntitySchema('block_content');
29
30     $this->executeMigrations([
31       'd7_filter_format',
32       'block_content_type',
33       'block_content_body_field',
34       'd7_custom_block',
35     ]);
36   }
37
38   /**
39    * Tests migration of custom blocks from Drupal 7 to Drupal 8.
40    */
41   public function testCustomBlockMigration() {
42     $block = BlockContent::load(1);
43     $this->assertTrue($block instanceof BlockContentInterface);
44     /** @var \Drupal\block_content\BlockContentInterface $block */
45     $this->assertIdentical('Limerick', $block->label());
46
47     $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";
48     $this->assertIdentical($expected_body, $block->body->value);
49     $this->assertIdentical('filtered_html', $block->body->format);
50   }
51
52 }