Commit 133dcccb authored by alexpott's avatar alexpott

Issue #2422229 by quietone, ultimike, vprocessor, anish.a, Jo Fitzgerald,...

Issue #2422229 by quietone, ultimike, vprocessor, anish.a, Jo Fitzgerald, phenaproxima: D6->D8 Core block migrations missing settings tests
parent a0dcc7f1
......@@ -21,6 +21,12 @@ class MigrateBlockTest extends MigrateDrupal6TestBase {
'comment',
'menu_ui',
'block_content',
'taxonomy',
'node',
'aggregator',
'book',
'forum',
'statistics',
];
/**
......@@ -30,15 +36,14 @@ protected function setUp() {
parent::setUp();
// Install the themes used for this test.
$this->container->get('theme_installer')->install(['bartik', 'seven', 'test_theme']);
$this->container->get('theme_installer')->install(['bartik', 'test_theme']);
$this->installConfig(['block_content']);
$this->installEntitySchema('block_content');
// Set Bartik and Seven as the default public and admin theme.
// Set Bartik as the default public theme.
$config = $this->config('system.theme');
$config->set('default', 'bartik');
$config->set('admin', 'seven');
$config->save();
$this->executeMigrations([
......@@ -46,7 +51,6 @@ protected function setUp() {
'block_content_type',
'block_content_body_field',
'd6_custom_block',
'menu',
'd6_user_role',
'd6_block',
]);
......@@ -66,14 +70,12 @@ protected function setUp() {
* The theme.
* @param string $weight
* The block weight.
* @param string $label
* The block label.
* @param string $label_display
* The block label display setting.
* @param array $settings
* (optional) The block settings.
* @param bool $status
* Whether the block is expected to be enabled or disabled.
*/
public function assertEntity($id, $visibility, $region, $theme, $weight, $label, $label_display, $status = TRUE) {
public function assertEntity($id, $visibility, $region, $theme, $weight, array $settings = NULL, $status = TRUE) {
$block = Block::load($id);
$this->assertTrue($block instanceof Block);
$this->assertSame($visibility, $block->getVisibility());
......@@ -81,10 +83,11 @@ public function assertEntity($id, $visibility, $region, $theme, $weight, $label,
$this->assertSame($theme, $block->getTheme());
$this->assertSame($weight, $block->getWeight());
$this->assertSame($status, $block->status());
$config = $this->config('block.block.' . $id);
$this->assertSame($label, $config->get('settings.label'));
$this->assertSame($label_display, $config->get('settings.label_display'));
if ($settings) {
$block_settings = $block->get('settings');
$block_settings['id'] = current(explode(':', $block_settings['id']));
$this->assertEquals($settings, $block_settings);
}
}
/**
......@@ -92,62 +95,209 @@ public function assertEntity($id, $visibility, $region, $theme, $weight, $label,
*/
public function testBlockMigration() {
$blocks = Block::loadMultiple();
$this->assertIdentical(9, count($blocks));
$this->assertCount(14, $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, '', '0');
// Check user blocks.
$visibility = [
'request_path' => [
'id' => 'request_path',
'negate' => TRUE,
'pages' => "<front>\n/node/1\n/blog/*",
],
];
$settings = [
'id' => 'user_login_block',
'label' => '',
'provider' => 'user',
'label_display' => '0',
];
$this->assertEntity('user', $visibility, 'sidebar_first', 'bartik', -10, $settings);
$visibility = [];
$this->assertEntity('user_1', $visibility, 'sidebar_first', 'bartik', 0, '', '0');
$settings = [
'id' => 'system_menu_block',
'label' => '',
'provider' => 'system',
'label_display' => '0',
'level' => 1,
'depth' => 0,
];
$this->assertEntity('user_1', $visibility, 'sidebar_first', 'bartik', -11, $settings);
$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, '', '0');
$visibility = [
'user_role' => [
'id' => 'user_role',
'roles' => [
'authenticated' => 'authenticated',
],
'context_mapping' => [
'user' => '@user.current_user_context:current_user',
],
'negate' => FALSE,
],
];
$settings = [
'id' => 'broken',
'label' => '',
'provider' => 'core',
'label_display' => '0',
'items_per_page' => '5',
];
$this->assertEntity('user_2', $visibility, 'sidebar_second', 'bartik', -11, $settings);
$visibility = [];
$visibility['user_role']['id'] = 'user_role';
$visibility['user_role']['roles'] = [
'migrate_test_role_1' => 'migrate_test_role_1'
$visibility = [
'user_role' => [
'id' => 'user_role',
'roles' => [
'migrate_test_role_1' => 'migrate_test_role_1',
],
'context_mapping' => [
'user' => '@user.current_user_context:current_user',
],
'negate' => FALSE,
],
];
$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, '', '0');
$settings = [
'id' => 'broken',
'label' => '',
'provider' => 'core',
'label_display' => '0',
'items_per_page' => '10',
];
$this->assertEntity('user_3', $visibility, 'sidebar_second', 'bartik', -10, $settings);
// 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_fifth', 'bartik', -5, '', '0');
// Check system block.
$visibility = [
'request_path' => [
'id' => 'request_path',
'negate' => TRUE,
'pages' => '/node/1',
],
];
$settings = [
'id' => 'system_powered_by_block',
'label' => '',
'provider' => 'system',
'label_display' => '0',
];
$this->assertEntity('system', $visibility, 'footer_fifth', 'bartik', -5, $settings);
// Check menu blocks
$visibility = [];
$this->assertEntity('menu', $visibility, 'header', 'bartik', -5, '', '0');
// Check menu blocks.
$settings = [
'id' => 'broken',
'label' => '',
'provider' => 'core',
'label_display' => '0',
];
$this->assertEntity('menu', [], 'header', 'bartik', -5, $settings);
// Check aggregator block.
$settings = [
'id' => 'aggregator_feed_block',
'label' => '',
'provider' => 'aggregator',
'label_display' => '0',
'block_count' => 7,
'feed' => '5',
];
$this->assertEntity('aggregator', [], 'sidebar_second', 'bartik', -2, $settings);
// Check book block.
$settings = [
'id' => 'book_navigation',
'label' => '',
'provider' => 'book',
'label_display' => '0',
'block_mode' => 'book pages',
];
$this->assertEntity('book', [], 'sidebar_second', 'bartik', -4, $settings);
// Check forum block settings.
$settings = [
'id' => 'forum_active_block',
'label' => '',
'provider' => 'forum',
'label_display' => '0',
'block_count' => 3,
'properties' => [
'administrative' => '1',
],
];
$this->assertEntity('forum', [], 'sidebar_first', 'bartik', -8, $settings);
$settings = [
'id' => 'forum_new_block',
'label' => '',
'provider' => 'forum',
'label_display' => '0',
'block_count' => 4,
'properties' => [
'administrative' => '1',
],
];
$this->assertEntity('forum_1', [], 'sidebar_first', 'bartik', -9, $settings);
// 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, 'Static Block', 'visible');
// Check statistic block settings.
$settings = [
'id' => 'broken',
'label' => '',
'provider' => 'core',
'label_display' => '0',
'top_day_num' => 7,
'top_all_num' => 8,
'top_last_num' => 9,
];
$this->assertEntity('statistics', [], 'sidebar_second', 'bartik', 0, $settings);
$visibility['request_path']['id'] = 'request_path';
$visibility['request_path']['negate'] = FALSE;
$visibility['request_path']['pages'] = '/node';
// Check custom blocks.
$visibility = [
'request_path' => [
'id' => 'request_path',
'negate' => FALSE,
'pages' => '<front>',
],
];
$settings = [
'id' => 'block_content',
'label' => 'Static Block',
'provider' => 'block_content',
'label_display' => 'visible',
'status' => TRUE,
'info' => '',
'view_mode' => 'full',
];
$this->assertEntity('block', $visibility, 'content', 'bartik', 0, $settings);
$visibility = [
'request_path' => [
'id' => 'request_path',
'negate' => FALSE,
'pages' => '/node',
],
];
$settings = [
'id' => 'block_content',
'label' => 'Another Static Block',
'provider' => 'block_content',
'label_display' => 'visible',
'status' => TRUE,
'info' => '',
'view_mode' => 'full',
];
// We expect this block to be disabled because '' is not a valid region,
// and block_rebuild() will disable any block in an invalid region.
$this->assertEntity('block_1', $visibility, '', 'bluemarine', -4, 'Another Static Block', 'visible', FALSE);
$this->assertEntity('block_1', $visibility, '', 'bluemarine', -4, $settings, FALSE);
$visibility = [];
$this->assertEntity('block_2', $visibility, 'right', 'test_theme', -7, '', '0');
$settings = [
'id' => 'block_content',
'label' => '',
'provider' => 'block_content',
'label_display' => '0',
'status' => TRUE,
'info' => '',
'view_mode' => 'full',
];
$this->assertEntity('block_2', [], 'right', 'test_theme', -7, $settings);
// Custom block with php code is not migrated.
$block = Block::load('block_3');
......
......@@ -33,7 +33,7 @@ protected function setUp() {
public function testBookSettings() {
$config = $this->config('book.settings');
$this->assertIdentical('book', $config->get('child_type'));
$this->assertIdentical('all pages', $config->get('block.navigation.mode'));
$this->assertSame('book pages', $config->get('block.navigation.mode'));
$this->assertIdentical(['book'], $config->get('allowed_types'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'book.settings', $config->get());
}
......
......@@ -38,9 +38,9 @@ public function testForumSettings() {
$this->assertIdentical(1, $config->get('topics.order'));
$this->assertIdentical('vocabulary_1_i_0_', $config->get('vocabulary'));
// This is 'forum_block_num_0' in D6, but block:active:limit' in D8.
$this->assertIdentical(5, $config->get('block.active.limit'));
$this->assertSame(3, $config->get('block.active.limit'));
// This is 'forum_block_num_1' in D6, but 'block:new:limit' in D8.
$this->assertIdentical(5, $config->get('block.new.limit'));
$this->assertSame(4, $config->get('block.new.limit'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'forum.settings', $config->get());
}
......
......@@ -33,17 +33,18 @@ public function testMigrateDependenciesOrder() {
'd6_node:company',
'd6_node:employee',
'd6_node:event',
'd6_node:forum',
'd6_node:page',
'd6_user',
'd6_node_type',
'd6_node_settings',
'd6_filter_format',
'd6_node:sponsor',
'd6_node:story',
'd6_node:test_event',
'd6_node:test_page',
'd6_node:test_planet',
'd6_node:test_story',
'd6_node_type',
'd6_node_settings',
'd6_filter_format',
'd6_user',
'd6_comment_type',
'd6_comment_entity_display',
'd6_comment_entity_form_display',
......
......@@ -426,7 +426,7 @@ class MigrateUpgradeForm extends ConfirmFormBase {
'source_module' => 'simpletest',
'destination_module' => 'simpletest',
],
'd6_statistics_settings' => [
'statistics_settings' => [
'source_module' => 'statistics',
'destination_module' => 'statistics',
],
......
......@@ -30,7 +30,16 @@ abstract class MigrateUpgradeTestBase extends WebTestBase {
*
* @var array
*/
public static $modules = ['language', 'content_translation', 'migrate_drupal_ui', 'telephone'];
public static $modules = [
'language',
'content_translation',
'migrate_drupal_ui',
'telephone',
'aggregator',
'book',
'forum',
'statistics',
];
/**
* {@inheritdoc}
......@@ -143,8 +152,9 @@ public function testMigrateUpgrade() {
$this->resetAll();
$expected_counts = $this->getEntityCounts();
foreach (array_keys(\Drupal::entityTypeManager()->getDefinitions()) as $entity_type) {
$real_count = count(\Drupal::entityTypeManager()->getStorage($entity_type)->loadMultiple());
foreach (array_keys(\Drupal::entityTypeManager()
->getDefinitions()) as $entity_type) {
$real_count = \Drupal::entityQuery($entity_type)->count()->execute();
$expected_count = isset($expected_counts[$entity_type]) ? $expected_counts[$entity_type] : 0;
$this->assertEqual($expected_count, $real_count, "Found $real_count $entity_type entities, expected $expected_count.");
}
......
......@@ -34,42 +34,44 @@ protected function getSourceBasePath() {
*/
protected function getEntityCounts() {
return [
'block' => 30,
'aggregator_item' => 1,
'aggregator_feed' => 1,
'block' => 35,
'block_content' => 2,
'block_content_type' => 1,
'comment' => 3,
'comment_type' => 2,
'comment_type' => 3,
'contact_form' => 5,
'configurable_language' => 5,
'editor' => 2,
'field_config' => 63,
'field_storage_config' => 43,
'field_config' => 71,
'field_storage_config' => 46,
'file' => 7,
'filter_format' => 7,
'image_style' => 5,
'language_content_settings' => 2,
'migration' => 105,
'node' => 11,
'node_type' => 11,
'rdf_mapping' => 5,
'node_type' => 13,
'rdf_mapping' => 7,
'search_page' => 2,
'shortcut' => 2,
'shortcut_set' => 1,
'action' => 22,
'menu' => 8,
'taxonomy_term' => 6,
'taxonomy_vocabulary' => 5,
'taxonomy_vocabulary' => 6,
'tour' => 4,
'user' => 7,
'user_role' => 6,
'menu_link_content' => 4,
'view' => 12,
'view' => 14,
'date_format' => 11,
'entity_form_display' => 15,
'entity_form_display' => 19,
'entity_form_mode' => 1,
'entity_view_display' => 32,
'entity_view_mode' => 12,
'base_field_override' => 33,
'entity_view_display' => 41,
'entity_view_mode' => 14,
'base_field_override' => 38,
];
}
......
......@@ -34,17 +34,19 @@ protected function getSourceBasePath() {
*/
protected function getEntityCounts() {
return [
'aggregator_item' => 10,
'aggregator_feed' => 1,
'block' => 25,
'block_content' => 1,
'block_content_type' => 1,
'comment' => 1,
'comment_type' => 7,
'comment_type' => 8,
// Module 'language' comes with 'en', 'und', 'zxx'. Migration adds 'is'.
'configurable_language' => 4,
'contact_form' => 3,
'editor' => 2,
'field_config' => 49,
'field_storage_config' => 37,
'field_config' => 52,
'field_storage_config' => 39,
'file' => 2,
'filter_format' => 7,
'image_style' => 6,
......@@ -52,7 +54,7 @@ protected function getEntityCounts() {
'migration' => 73,
'node' => 3,
'node_type' => 6,
'rdf_mapping' => 5,
'rdf_mapping' => 7,
'search_page' => 2,
'shortcut' => 6,
'shortcut_set' => 2,
......@@ -64,13 +66,13 @@ protected function getEntityCounts() {
'user' => 4,
'user_role' => 3,
'menu_link_content' => 7,
'view' => 12,
'view' => 14,
'date_format' => 11,
'entity_form_display' => 16,
'entity_form_display' => 18,
'entity_form_mode' => 1,
'entity_view_display' => 24,
'entity_view_mode' => 11,
'base_field_override' => 7,
'entity_view_display' => 29,
'entity_view_mode' => 14,
'base_field_override' => 9,
];
}
......
......@@ -32,7 +32,7 @@ protected function setUp() {
*/
public function testStatisticsSettings() {
$config = $this->config('statistics.settings');
$this->assertIdentical(0, $config->get('count_content_views'));
$this->assertSame(1, $config->get('count_content_views'));
$this->assertConfigSchema(\Drupal::service('config.typed'), 'statistics.settings', $config->get());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment