MigrateCustomBlockTest.php 1.42 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\block_content\Kernel\Migrate\d7;
4 5 6

use Drupal\block_content\BlockContentInterface;
use Drupal\block_content\Entity\BlockContent;
7
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
8 9 10 11 12 13 14 15

/**
 * Tests migration of custom blocks.
 *
 * @group block_content
 */
class MigrateCustomBlockTest extends MigrateDrupal7TestBase {

16
  protected static $modules = [
17 18 19
    'block_content',
    'filter',
    'text',
20
  ];
21 22 23 24

  /**
   * {@inheritdoc}
   */
25
  protected function setUp(): void {
26 27
    parent::setUp();
    $this->installEntitySchema('block_content');
28
    $this->installConfig(static::$modules);
29

30 31 32 33 34 35
    $this->executeMigrations([
      'd7_filter_format',
      'block_content_type',
      'block_content_body_field',
      'd7_custom_block',
    ]);
36 37 38 39 40 41 42
  }

  /**
   * Tests migration of custom blocks from Drupal 7 to Drupal 8.
   */
  public function testCustomBlockMigration() {
    $block = BlockContent::load(1);
43
    $this->assertInstanceOf(BlockContentInterface::class, $block);
44 45 46 47 48 49 50 51 52
    /** @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);
  }

}