function MigrateBlockTest::testBlockMigration

Same name in this branch
  1. 8.9.x core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d6\MigrateBlockTest::testBlockMigration()
Same name in other branches
  1. 9 core/modules/aggregator/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\aggregator\Kernel\Migrate\d6\MigrateBlockTest::testBlockMigration()
  2. 9 core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d6\MigrateBlockTest::testBlockMigration()
  3. 9 core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d7\MigrateBlockTest::testBlockMigration()
  4. 10 core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\forum\Kernel\Migrate\d6\MigrateBlockTest::testBlockMigration()
  5. 10 core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d6\MigrateBlockTest::testBlockMigration()
  6. 10 core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d7\MigrateBlockTest::testBlockMigration()
  7. 11.x core/modules/forum/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\forum\Kernel\Migrate\d6\MigrateBlockTest::testBlockMigration()
  8. 11.x core/modules/block/tests/src/Kernel/Migrate/d6/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d6\MigrateBlockTest::testBlockMigration()
  9. 11.x core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php \Drupal\Tests\block\Kernel\Migrate\d7\MigrateBlockTest::testBlockMigration()

Tests the block migration.

File

core/modules/block/tests/src/Kernel/Migrate/d7/MigrateBlockTest.php, line 113

Class

MigrateBlockTest
Tests migration of blocks to configuration entities.

Namespace

Drupal\Tests\block\Kernel\Migrate\d7

Code

public function testBlockMigration() {
    $this->assertEntity('bartik_system_main', 'system_main_block', [], '', 'content', 'bartik', 0, '', '0');
    $this->assertEntity('bartik_search_form', 'search_form_block', [], '', 'sidebar_first', 'bartik', -1, '', '0');
    $this->assertEntity('bartik_user_login', 'user_login_block', [], '', 'sidebar_first', 'bartik', 0, 'User login title', 'visible');
    $this->assertEntity('bartik_system_powered_by', 'system_powered_by_block', [], '', 'footer_fifth', 'bartik', 10, '', '0');
    $this->assertEntity('seven_system_main', 'system_main_block', [], '', 'content', 'seven', 0, '', '0');
    $this->assertEntity('seven_user_login', 'user_login_block', [], '', 'content', 'seven', 10, 'User login title', 'visible');
    // The d7_custom_block migration should have migrated a block containing a
    // mildly amusing limerick. We'll need its UUID to determine
    // bartik_block_1's plugin ID.
    $uuid = BlockContent::load(1)->uuid();
    $this->assertEntity('bartik_block_1', 'block_content:' . $uuid, [
        'authenticated',
    ], '', 'highlighted', 'bartik', 0, 'Mildly amusing limerick of the day', 'visible');
    // Assert that disabled blocks (or enabled blocks whose plugin IDs could
    // be resolved) did not migrate.
    $non_existent_blocks = [
        'bartik_system_navigation',
        'bartik_system_help',
        'seven_user_new',
        'seven_search_form',
        'bartik_comment_recent',
        'bartik_node_syndicate',
        'bartik_node_recent',
        'bartik_shortcut_shortcuts',
        'bartik_system_management',
        'bartik_system_user-menu',
        'bartik_system_main-menu',
        'bartik_user_new',
        'bartik_user_online',
        'seven_comment_recent',
        'seven_node_syndicate',
        'seven_shortcut_shortcuts',
        'seven_system_powered-by',
        'seven_system_navigation',
        'seven_system_management',
        'seven_system_user-menu',
        'seven_system_main-menu',
        'seven_user_online',
        'bartik_blog_recent',
        'bartik_book_navigation',
        'bartik_locale_language',
        'bartik_forum_active',
        'bartik_forum_new',
        'seven_blog_recent',
        'seven_book_navigation',
        'seven_locale_language',
        'seven_forum_active',
        'seven_forum_new',
        'bartik_menu_menu-test-menu',
        'bartik_statistics_popular',
        'seven_menu_menu-test-menu',
        'seven_statistics_popular',
        'seven_block_1',
    ];
    $this->assertTrue(empty(Block::loadMultiple($non_existent_blocks)));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.