Commit 10ea52ea authored by webchick's avatar webchick

Issue #2563819 by phenaproxima, mikeryan: [D7] Field display settings do not migrate

parent 50585b22
......@@ -15,12 +15,12 @@ process:
plugin: migration
migration: d7_field
source:
- entity_type
- field_name
- entity_type
-
plugin: extract
index:
- 1
- 0
-
plugin: skip_on_empty
method: row
......@@ -44,6 +44,7 @@ process:
phone_textfield: telephone_default
options_onoff: boolean_checkbox
entityreference_autocomplete: entity_reference_autocomplete
taxonomy_autocomplete: entity_reference_autocomplete
'options/settings':
plugin: field_instance_widget_settings
source:
......
......@@ -10,7 +10,6 @@
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\NodeType;
/**
* Migrate field widget settings.
......@@ -25,29 +24,19 @@ class MigrateFieldInstanceWidgetSettingsTest extends MigrateDrupal7TestBase {
* @var array
*/
public static $modules = array(
'comment',
'datetime',
'entity_reference',
'field',
'telephone',
'link',
'file',
'image',
'datetime',
'link',
'node',
'taxonomy',
'telephone',
'text',
);
/**
* Creates a node type.
*
* @param string $id
* The node type ID.
*/
protected function createNodeType($id) {
NodeType::create(array(
'type' => $id,
'label' => $this->randomString(),
))->save();
}
/**
* {@inheritdoc}
*/
......@@ -55,45 +44,14 @@ protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->createNodeType('page');
$this->createNodeType('article');
$this->createNodeType('blog');
$this->createNodeType('book');
$this->createNodeType('forum');
$this->createNodeType('test_content_type');
// Add some id mappings for the dependent migrations.
$id_mappings = [
'd7_field' => [
[['comment', 'comment_body'], ['comment', 'comment_body']],
[['node', 'body'], ['node', 'body']],
[['node', 'field_tags'], ['node', 'field_tags']],
[['node', 'field_image'], ['node', 'field_image']],
[['node', 'taxonomy_forums'], ['node', 'taxonomy_forums']],
[['node', 'field_boolean'], ['node', 'field_boolean']],
[['node', 'field_email'], ['node', 'field_email']],
[['node', 'field_phone'], ['node', 'field_phone']],
[['node', 'field_date'], ['node', 'field_date']],
[['node', 'field_date_with_end_time'], ['node', 'field_date_with_end_time']],
[['node', 'field_file'], ['node', 'field_file']],
[['node', 'field_float'], ['node', 'field_float']],
[['node', 'field_images'], ['node', 'field_images']],
[['node', 'field_integer'], ['node', 'field_integer']],
[['node', 'field_link'], ['node', 'field_link']],
[['node', 'field_text_list'], ['node', 'field_text_list']],
[['node', 'field_integer_list'], ['node', 'field_integer_list']],
[['node', 'field_long_text'], ['node', 'field_long_text']],
[['node', 'field_term_reference'], ['node', 'field_term_reference']],
[['node', 'field_text'], ['node', 'field_text']],
[['node', 'field_integer'], ['node', 'field_integer']],
[['user', 'field_file'], ['user', 'field_file']],
],
// We don't actually need any ID lookups from the d7_field_instance
// migration -- it's merely a sensible dependency.
'd7_field_instance' => [],
];
$this->prepareMigrations($id_mappings);
$this->installEntitySchema('comment');
$this->installEntitySchema('taxonomy_term');
$this->installConfig(static::$modules);
$this->executeMigration('d7_node_type');
$this->executeMigration('d7_comment_type');
$this->executeMigration('d7_field');
$this->executeMigration('d7_field_instance');
$this->executeMigration('d7_field_instance_widget_settings');
}
......@@ -143,7 +101,7 @@ public function testWidgetSettings() {
$this->assertEntity('node.article.default', 'node', 'article');
$this->assertComponent('node.article.default', 'body', 'text_textarea_with_summary', -4);
$this->assertComponent('node.article.default', 'field_tags', 'taxonomy_autocomplete', -4);
$this->assertComponent('node.article.default', 'field_tags', 'entity_reference_autocomplete', -4);
$this->assertComponent('node.article.default', 'field_image', 'image_image', -1);
$this->assertEntity('node.blog.default', 'node', 'blog');
......@@ -169,7 +127,7 @@ public function testWidgetSettings() {
$this->assertComponent('node.test_content_type.default', 'field_integer_list', 'options_buttons', 12);
$this->assertComponent('node.test_content_type.default', 'field_long_text', 'text_textarea_with_summary', 13);
$this->assertComponent('node.test_content_type.default', 'field_phone', 'telephone_default', 6);
$this->assertComponent('node.test_content_type.default', 'field_term_reference', 'taxonomy_autocomplete', 14);
$this->assertComponent('node.test_content_type.default', 'field_term_reference', 'entity_reference_autocomplete', 14);
$this->assertComponent('node.test_content_type.default', 'field_text', 'text_textfield', 15);
$this->assertComponent('node.test_content_type.default', 'field_text_list', 'options_select', 11);
}
......
......@@ -30,3 +30,5 @@ migration_dependencies:
required:
- d7_user
- d7_node_type
optional:
- d7_field_instance
......@@ -18,7 +18,17 @@
*/
class MigrateNodeTest extends MigrateDrupal7TestBase {
static $modules = array('node', 'text', 'filter', 'entity_reference');
static $modules = array(
'comment',
'datetime',
'entity_reference',
'filter',
'image',
'link',
'node',
'telephone',
'text',
);
/**
* {@inheritdoc}
......@@ -27,13 +37,17 @@ protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installConfig(['node']);
$this->installEntitySchema('comment');
$this->installConfig(static::$modules);
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['sequences']);
$this->executeMigration('d7_user_role');
$this->executeMigration('d7_user');
$this->executeMigration('d7_node_type');
$this->executeMigration('d7_comment_type');
$this->executeMigration('d7_field');
$this->executeMigration('d7_field_instance');
$this->executeMigration('d7_node__test_content_type');
}
......@@ -107,6 +121,15 @@ protected function assertRevision($id, $title, $uid, $log, $timestamp) {
public function testNode() {
$this->assertEntity(1, 'test_content_type', 'en', 'A Node', '2', TRUE, '1421727515', '1441032132', TRUE, FALSE);
$this->assertRevision(1, 'A Node', '2', NULL, '1441032132');
$node = Node::load(1);
$this->assertTrue($node->field_boolean->value);
$this->assertIdentical('99-99-99-99', $node->field_phone->value);
$this->assertIdentical('1', $node->field_float->value);
$this->assertIdentical('5', $node->field_integer->value);
$this->assertIdentical('Some more text', $node->field_text_list[0]->value);
$this->assertIdentical('7', $node->field_integer_list[0]->value);
$this->assertIdentical('qwerty', $node->field_text->value);
}
}
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