3 namespace Drupal\Tests\block_content\Kernel\Migrate\d6;
5 use Drupal\block_content\Entity\BlockContent;
6 use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
9 * Tests migration of i18n custom block strings.
11 * @group migrate_drupal_6
13 class MigrateCustomBlockContentTranslationTest extends MigrateDrupal6TestBase {
18 public static $modules = [
20 'content_translation',
22 // Required for translation migrations.
23 'migrate_drupal_multilingual',
29 protected function setUp() {
31 $this->installConfig(['block_content']);
32 $this->installEntitySchema('block_content');
33 $this->executeMigrations([
37 'block_content_body_field',
39 'd6_custom_block_translation',
44 * Tests the Drupal 6 i18n custom block strings to Drupal 8 migration.
46 public function testCustomBlockContentTranslation() {
47 /** @var \Drupal\block_content\Entity\BlockContent $block */
48 $block = BlockContent::load(1)->getTranslation('fr');
49 $this->assertSame('fr - Static Block', $block->label());
50 $this->assertGreaterThanOrEqual(REQUEST_TIME, $block->getChangedTime());
51 $this->assertLessThanOrEqual(time(), $block->getChangedTime());
52 $this->assertSame('fr', $block->language()->getId());
53 $this->assertSame('<h3>fr - My first custom block body</h3>', $block->body->value);
54 $this->assertSame('full_html', $block->body->format);
56 $block = $block->getTranslation('zu');
57 $this->assertSame('My block 1', $block->label());
58 $this->assertGreaterThanOrEqual(REQUEST_TIME, $block->getChangedTime());
59 $this->assertLessThanOrEqual(time(), $block->getChangedTime());
60 $this->assertSame('zu', $block->language()->getId());
61 $this->assertSame('<h3>zu - My first custom block body</h3>', $block->body->value);
62 $this->assertSame('full_html', $block->body->format);
64 $block = BlockContent::load(2)->getTranslation('fr');
65 $this->assertSame('Encore un bloc statique', $block->label());
66 $this->assertGreaterThanOrEqual(REQUEST_TIME, $block->getChangedTime());
67 $this->assertLessThanOrEqual(time(), $block->getChangedTime());
68 $this->assertSame('fr', $block->language()->getId());
69 $this->assertSame('Nom de vocabulaire beaucoup plus long que trente-deux caractères', $block->body->value);
70 $this->assertSame('full_html', $block->body->format);