MigrateCustomBlockTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Drupal\Tests\block_content\Kernel\Migrate\d7;
  3. use Drupal\block_content\BlockContentInterface;
  4. use Drupal\block_content\Entity\BlockContent;
  5. use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
  6. /**
  7. * Tests migration of custom blocks.
  8. *
  9. * @group block_content
  10. */
  11. class MigrateCustomBlockTest extends MigrateDrupal7TestBase {
  12. public static $modules = [
  13. 'block_content',
  14. 'filter',
  15. 'text',
  16. ];
  17. /**
  18. * {@inheritdoc}
  19. */
  20. protected function setUp() {
  21. parent::setUp();
  22. $this->installConfig(static::$modules);
  23. $this->installEntitySchema('block_content');
  24. $this->executeMigrations([
  25. 'd7_filter_format',
  26. 'block_content_type',
  27. 'block_content_body_field',
  28. 'd7_custom_block',
  29. ]);
  30. }
  31. /**
  32. * Tests migration of custom blocks from Drupal 7 to Drupal 8.
  33. */
  34. public function testCustomBlockMigration() {
  35. $block = BlockContent::load(1);
  36. $this->assertTrue($block instanceof BlockContentInterface);
  37. /** @var \Drupal\block_content\BlockContentInterface $block */
  38. $this->assertIdentical('Limerick', $block->label());
  39. $expected_body = "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";
  40. $this->assertIdentical($expected_body, $block->body->value);
  41. $this->assertIdentical('filtered_html', $block->body->format);
  42. }
  43. }