You are here

public function MigrateCustomBlockContentTranslationTest::testCustomBlockContentTranslation in Drupal 10

Same name in this branch
  1. 10 core/modules/block_content/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php \Drupal\Tests\block_content\Kernel\Migrate\d6\MigrateCustomBlockContentTranslationTest::testCustomBlockContentTranslation()
  2. 10 core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockContentTranslationTest.php \Drupal\Tests\block_content\Kernel\Migrate\d7\MigrateCustomBlockContentTranslationTest::testCustomBlockContentTranslation()
Same name and namespace in other branches
  1. 8 core/modules/block_content/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php \Drupal\Tests\block_content\Kernel\Migrate\d6\MigrateCustomBlockContentTranslationTest::testCustomBlockContentTranslation()
  2. 9 core/modules/block_content/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php \Drupal\Tests\block_content\Kernel\Migrate\d6\MigrateCustomBlockContentTranslationTest::testCustomBlockContentTranslation()

Tests the Drupal 6 i18n custom block strings to Drupal 8 migration.

File

core/modules/block_content/tests/src/Kernel/Migrate/d6/MigrateCustomBlockContentTranslationTest.php, line 44

Class

MigrateCustomBlockContentTranslationTest
Tests migration of i18n custom block strings.

Namespace

Drupal\Tests\block_content\Kernel\Migrate\d6

Code

public function testCustomBlockContentTranslation() {

  /** @var \Drupal\block_content\Entity\BlockContent $block */
  $block = BlockContent::load(1)
    ->getTranslation('fr');
  $this
    ->assertSame('fr - Static Block', $block
    ->label());
  $this
    ->assertGreaterThanOrEqual(REQUEST_TIME, $block
    ->getChangedTime());
  $this
    ->assertLessThanOrEqual(time(), $block
    ->getChangedTime());
  $this
    ->assertSame('fr', $block
    ->language()
    ->getId());
  $this
    ->assertSame('<h3>fr - My first custom block body</h3>', $block->body->value);
  $this
    ->assertSame('full_html', $block->body->format);
  $block = $block
    ->getTranslation('zu');
  $this
    ->assertSame('My block 1', $block
    ->label());
  $this
    ->assertGreaterThanOrEqual(REQUEST_TIME, $block
    ->getChangedTime());
  $this
    ->assertLessThanOrEqual(time(), $block
    ->getChangedTime());
  $this
    ->assertSame('zu', $block
    ->language()
    ->getId());
  $this
    ->assertSame('<h3>zu - My first custom block body</h3>', $block->body->value);
  $this
    ->assertSame('full_html', $block->body->format);
  $block = BlockContent::load(2)
    ->getTranslation('fr');
  $this
    ->assertSame('Encore un bloc statique', $block
    ->label());
  $this
    ->assertGreaterThanOrEqual(REQUEST_TIME, $block
    ->getChangedTime());
  $this
    ->assertLessThanOrEqual(time(), $block
    ->getChangedTime());
  $this
    ->assertSame('fr', $block
    ->language()
    ->getId());
  $this
    ->assertSame('Nom de vocabulaire beaucoup plus long que trente-deux caractères', $block->body->value);
  $this
    ->assertSame('full_html', $block->body->format);
}