MigrateBlockContentTest.php 1.87 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\block_content\Tests\Migrate\d6\MigrateBlockContentTest.
6 7
 */

8
namespace Drupal\block_content\Tests\Migrate\d6;
9

10
use Drupal\block_content\Entity\BlockContent;
11
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
12 13

/**
14 15
 * Upgrade custom blocks.
 *
16
 * @group block_content
17
 */
18
class MigrateBlockContentTest extends MigrateDrupal6TestBase {
19

20
  static $modules = array('block', 'block_content', 'filter', 'text');
21 22 23 24

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

30 31
    $this->executeMigration('d6_block_content_type');
    $this->executeMigration('d6_block_content_body_field');
32

33
    $this->prepareMigrations(array(
34 35 36 37
      'd6_filter_format' => array(
        array(array(2), array('full_html'))
      )
    ));
38
    $this->executeMigration('d6_custom_block');
39 40 41 42 43 44
  }

  /**
   * Tests the Drupal 6 custom block to Drupal 8 migration.
   */
  public function testBlockMigration() {
45
    /** @var BlockContent $block */
46
    $block = BlockContent::load(1);
47
    $this->assertIdentical('My block 1', $block->label());
48
    $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
49 50 51
    $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);
52

53
    $block = BlockContent::load(2);
54
    $this->assertIdentical('My block 2', $block->label());
55
    $this->assertTrue(REQUEST_TIME <= $block->getChangedTime() && $block->getChangedTime() <= time());
56 57 58
    $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);
59 60 61
  }

}