public function MigrateBlockTest::testBlockMigration in Zircon Profile 8
Same name in this branch
- 8 core/modules/block/src/Tests/Migrate/d6/MigrateBlockTest.php \Drupal\block\Tests\Migrate\d6\MigrateBlockTest::testBlockMigration()
- 8 core/modules/block/src/Tests/Migrate/d7/MigrateBlockTest.php \Drupal\block\Tests\Migrate\d7\MigrateBlockTest::testBlockMigration()
Same name and namespace in other branches
- 8.0 core/modules/block/src/Tests/Migrate/d6/MigrateBlockTest.php \Drupal\block\Tests\Migrate\d6\MigrateBlockTest::testBlockMigration()
Tests the block migration.
File
- core/
modules/ block/ src/ Tests/ Migrate/ d6/ MigrateBlockTest.php, line 85 - Contains \Drupal\block\Tests\Migrate\d6\MigrateBlockTest.
Class
- MigrateBlockTest
- Tests migration of blocks to configuration entities.
Namespace
Drupal\block\Tests\Migrate\d6Code
public function testBlockMigration() {
$blocks = Block::loadMultiple();
$this
->assertIdentical(9, count($blocks));
// User blocks
$visibility = [];
$visibility['request_path']['id'] = 'request_path';
$visibility['request_path']['negate'] = TRUE;
$visibility['request_path']['pages'] = "<front>\n/node/1\n/blog/*";
$this
->assertEntity('user', $visibility, 'sidebar_first', 'bartik', 0);
$visibility = [];
$this
->assertEntity('user_1', $visibility, 'sidebar_first', 'bartik', 0);
$visibility['user_role']['id'] = 'user_role';
$roles['authenticated'] = 'authenticated';
$visibility['user_role']['roles'] = $roles;
$context_mapping['user'] = '@user.current_user_context:current_user';
$visibility['user_role']['context_mapping'] = $context_mapping;
$visibility['user_role']['negate'] = FALSE;
$this
->assertEntity('user_2', $visibility, 'sidebar_second', 'bartik', -9);
$visibility = [];
$visibility['user_role']['id'] = 'user_role';
$visibility['user_role']['roles'] = [
'migrate_test_role_1' => 'migrate_test_role_1',
];
$context_mapping['user'] = '@user.current_user_context:current_user';
$visibility['user_role']['context_mapping'] = $context_mapping;
$visibility['user_role']['negate'] = FALSE;
$this
->assertEntity('user_3', $visibility, 'sidebar_second', 'bartik', -6);
// Check system block
$visibility = [];
$visibility['request_path']['id'] = 'request_path';
$visibility['request_path']['negate'] = TRUE;
$visibility['request_path']['pages'] = '/node/1';
$this
->assertEntity('system', $visibility, 'footer', 'bartik', -5);
// Check menu blocks
$visibility = [];
$this
->assertEntity('menu', $visibility, 'header', 'bartik', -5);
// Check custom blocks
$visibility['request_path']['id'] = 'request_path';
$visibility['request_path']['negate'] = FALSE;
$visibility['request_path']['pages'] = '<front>';
$this
->assertEntity('block', $visibility, 'content', 'bartik', 0);
$visibility['request_path']['id'] = 'request_path';
$visibility['request_path']['negate'] = FALSE;
$visibility['request_path']['pages'] = '/node';
$this
->assertEntity('block_1', $visibility, 'sidebar_second', 'bluemarine', -4);
$visibility = [];
$this
->assertEntity('block_2', $visibility, 'right', 'test_theme', -7);
// Custom block with php code is not migrated.
$block = Block::load('block_3');
$this
->assertFalse($block instanceof Block);
}