MigrateBlockContentTest.php 1.7 KB
Newer Older
1 2
<?php

3
namespace Drupal\Tests\block_content\Kernel\Migrate\d6;
4

5
use Drupal\block_content\Entity\BlockContent;
6
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
7 8

/**
9 10
 * Upgrade custom blocks.
 *
11
 * @group migrate_drupal_6
12
 */
13
class MigrateBlockContentTest extends MigrateDrupal6TestBase {
14

15 16 17
  /**
   * {@inheritdoc}
   */
18
  public static $modules = ['block', 'block_content'];
19 20 21 22

  /**
   * {@inheritdoc}
   */
23
  protected function setUp() {
24
    parent::setUp();
25
    $this->installEntitySchema('block_content');
26
    $this->installConfig(['block_content']);
27

28 29 30 31 32 33
    $this->executeMigrations([
      'd6_filter_format',
      'block_content_type',
      'block_content_body_field',
      'd6_custom_block',
    ]);
34 35 36 37 38 39
  }

  /**
   * Tests the Drupal 6 custom block to Drupal 8 migration.
   */
  public function testBlockMigration() {
40
    /** @var \Drupal\block_content\Entity\BlockContent $block */
41
    $block = BlockContent::load(1);
42
    $this->assertIdentical('My block 1', $block->label());
43
    $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
44 45 46
    $this->assertIdentical('en', $block->language()->getId());
    $this->assertIdentical('<h3>My first custom block body</h3>', $block->body->value);
    $this->assertIdentical('full_html', $block->body->format);
47

48
    $block = BlockContent::load(2);
49
    $this->assertIdentical('My block 2', $block->label());
50
    $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
51 52 53
    $this->assertIdentical('en', $block->language()->getId());
    $this->assertIdentical('<h3>My second custom block body</h3>', $block->body->value);
    $this->assertIdentical('full_html', $block->body->format);
54 55 56
  }

}