X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Fmodules%2Fblock_content%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd7%2FMigrateCustomBlockContentTranslationTest.php;fp=web%2Fcore%2Fmodules%2Fblock_content%2Ftests%2Fsrc%2FKernel%2FMigrate%2Fd7%2FMigrateCustomBlockContentTranslationTest.php;h=092eb0a853d44fcda40ae3ebbcb3c4c1fa4b9a97;hb=0bf8d09d2542548982e81a441b1f16e75873a04f;hp=0000000000000000000000000000000000000000;hpb=74df008bdbb3a11eeea356744f39b802369bda3c;p=yaffs-website diff --git a/web/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockContentTranslationTest.php b/web/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockContentTranslationTest.php new file mode 100644 index 000000000..092eb0a85 --- /dev/null +++ b/web/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockContentTranslationTest.php @@ -0,0 +1,69 @@ +installConfig(['block_content']); + $this->installEntitySchema('block_content'); + $this->executeMigrations([ + 'language', + 'd7_filter_format', + 'block_content_type', + 'block_content_body_field', + 'd7_custom_block', + 'd7_custom_block_translation', + ]); + } + + /** + * Tests the Drupal 7 i18n custom block strings to Drupal 8 migration. + */ + public function testCustomBlockContentTranslation() { + /** @var \Drupal\block_content\Entity\BlockContent $block */ + $block = BlockContent::load(1)->getTranslation('fr'); + $this->assertSame('fr - Mildly amusing limerick of the day', $block->label()); + $this->assertGreaterThanOrEqual($block->getChangedTime(), \Drupal::time()->getRequestTime()); + $this->assertLessThanOrEqual(time(), $block->getChangedTime()); + $this->assertSame('fr', $block->language()->getId()); + $translation = "fr - A fellow jumped off a high wall\r\nAnd had a most terrible fall\r\nHe went back to bed\r\nWith a bump on his head\r\nThat's why you don't jump off a wall"; + $this->assertSame($translation, $block->body->value); + $this->assertSame('filtered_html', $block->body->format); + + $block = $block->getTranslation('is'); + $this->assertSame('is - Mildly amusing limerick of the day', $block->label()); + $this->assertGreaterThanOrEqual($block->getChangedTime(), \Drupal::time()->getRequestTime()); + $this->assertLessThanOrEqual(time(), $block->getChangedTime()); + $this->assertSame('is', $block->language()->getId()); + $text = "A fellow jumped off a high wall\r\nAnd had a most terrible fall\r\nHe went back to bed\r\nWith a bump on his head\r\nThat's why you don't jump off a wall"; + $this->assertSame($text, $block->body->value); + $this->assertSame('filtered_html', $block->body->format); + } + +}