Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block_content / tests / src / Kernel / Migrate / d6 / MigrateCustomBlockContentTranslationTest.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  * Tests migration of i18n custom block strings.
10  *
11  * @group migrate_drupal_6
12  */
13 class MigrateCustomBlockContentTranslationTest extends MigrateDrupal6TestBase {
14
15   /**
16    * {@inheritdoc}
17    */
18   public static $modules = [
19     'block_content',
20     'content_translation',
21     'language',
22     // Required for translation migrations.
23     'migrate_drupal_multilingual',
24   ];
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function setUp() {
30     parent::setUp();
31     $this->installConfig(['block_content']);
32     $this->installEntitySchema('block_content');
33     $this->executeMigrations([
34       'language',
35       'd6_filter_format',
36       'block_content_type',
37       'block_content_body_field',
38       'd6_custom_block',
39       'd6_custom_block_translation',
40     ]);
41   }
42
43   /**
44    * Tests the Drupal 6 i18n custom block strings to Drupal 8 migration.
45    */
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);
55
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);
63
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);
71   }
72
73 }