Version 1
[yaffs-website] / web / core / modules / block_content / tests / src / Kernel / Migrate / d6 / MigrateBlockContentTest.php
1 <?php
2
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  * Upgrade custom blocks.
10  *
11  * @group migrate_drupal_6
12  */
13 class MigrateBlockContentTest extends MigrateDrupal6TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = ['block', 'block_content'];
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function setUp() {
24     parent::setUp();
25     $this->installConfig(['block_content']);
26     $this->installEntitySchema('block_content');
27
28     $this->executeMigrations([
29       'd6_filter_format',
30       'block_content_type',
31       'block_content_body_field',
32       'd6_custom_block',
33     ]);
34   }
35
36   /**
37    * Tests the Drupal 6 custom block to Drupal 8 migration.
38    */
39   public function testBlockMigration() {
40     /** @var 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     $this->assertIdentical('en', $block->language()->getId());
45     $this->assertIdentical('<h3>My first custom block body</h3>', $block->body->value);
46     $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     $this->assertIdentical('en', $block->language()->getId());
52     $this->assertIdentical('<h3>My second custom block body</h3>', $block->body->value);
53     $this->assertIdentical('full_html', $block->body->format);
54   }
55
56 }