Update to Drupal 8.1.8. For more information, see https://www.drupal.org/project/drupal/releases/8.1.8
This commit is contained in:
parent
e9f047ccf8
commit
f9f23cdf38
312 changed files with 6751 additions and 1546 deletions
|
@ -0,0 +1,182 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
- user
|
||||
id: test_node_path_plugin
|
||||
label: test_node_path_plugin
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'access content'
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
reset_button: false
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: full
|
||||
options:
|
||||
items_per_page: 10
|
||||
offset: 0
|
||||
id: 0
|
||||
total_pages: null
|
||||
expose:
|
||||
items_per_page: false
|
||||
items_per_page_label: 'Items per page'
|
||||
items_per_page_options: '5, 10, 25, 50'
|
||||
items_per_page_options_all: false
|
||||
items_per_page_options_all_label: '- All -'
|
||||
offset: false
|
||||
offset_label: Offset
|
||||
tags:
|
||||
previous: '‹ Previous'
|
||||
next: 'Next ›'
|
||||
first: '« First'
|
||||
last: 'Last »'
|
||||
quantity: 9
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
fields:
|
||||
path:
|
||||
id: path
|
||||
table: node
|
||||
field: path
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: true
|
||||
text: 'This is <strong>not escaped</strong> and this is <a href="{{ path }}" hreflang="en">the link</a>.'
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
absolute: false
|
||||
entity_type: node
|
||||
plugin_id: node_path
|
||||
filters:
|
||||
status:
|
||||
value: true
|
||||
table: node_field_data
|
||||
field: status
|
||||
plugin_id: boolean
|
||||
entity_type: node
|
||||
entity_field: status
|
||||
id: status
|
||||
expose:
|
||||
operator: ''
|
||||
group: 1
|
||||
sorts:
|
||||
created:
|
||||
id: created
|
||||
table: node_field_data
|
||||
field: created
|
||||
order: DESC
|
||||
entity_type: node
|
||||
entity_field: created
|
||||
plugin_id: date
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
exposed: false
|
||||
expose:
|
||||
label: ''
|
||||
granularity: second
|
||||
title: test_node_path_plugin
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_interface'
|
||||
- url.query_args
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags: { }
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: test-node-path-plugin
|
||||
cache_metadata:
|
||||
max-age: -1
|
||||
contexts:
|
||||
- 'languages:language_interface'
|
||||
- url.query_args
|
||||
- 'user.node_grants:view'
|
||||
- user.permissions
|
||||
tags: { }
|
|
@ -0,0 +1,224 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
id: test_node_revision_links
|
||||
label: test_node_revision_links
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node_field_revision
|
||||
base_field: vid
|
||||
core: '8'
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: none
|
||||
options: { }
|
||||
cache:
|
||||
type: none
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
reset_button: false
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: none
|
||||
options:
|
||||
items_per_page: 0
|
||||
offset: 0
|
||||
style:
|
||||
type: default
|
||||
row:
|
||||
type: fields
|
||||
fields:
|
||||
link_to_revision:
|
||||
id: link_to_revision
|
||||
table: node_field_revision
|
||||
field: link_to_revision
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
text: 'Link to revision'
|
||||
entity_type: node
|
||||
plugin_id: node_revision_link
|
||||
delete_revision:
|
||||
id: delete_revision
|
||||
table: node_field_revision
|
||||
field: delete_revision
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
text: 'Link to delete revision'
|
||||
entity_type: node
|
||||
plugin_id: node_revision_link_delete
|
||||
revert_revision:
|
||||
id: revert_revision
|
||||
table: node_field_revision
|
||||
field: revert_revision
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
make_link: false
|
||||
path: ''
|
||||
absolute: false
|
||||
external: false
|
||||
replace_spaces: false
|
||||
path_case: none
|
||||
trim_whitespace: false
|
||||
alt: ''
|
||||
rel: ''
|
||||
link_class: ''
|
||||
prefix: ''
|
||||
suffix: ''
|
||||
target: ''
|
||||
nl2br: false
|
||||
max_length: 0
|
||||
word_boundary: true
|
||||
ellipsis: true
|
||||
more_link: false
|
||||
more_link_text: ''
|
||||
more_link_path: ''
|
||||
strip_tags: false
|
||||
trim: false
|
||||
preserve_tags: ''
|
||||
html: false
|
||||
element_type: ''
|
||||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
empty: ''
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
text: 'Link to delete revision'
|
||||
entity_type: node
|
||||
plugin_id: node_revision_link_revert
|
||||
filters: { }
|
||||
sorts: { }
|
||||
title: test_node_revision_links
|
||||
header: { }
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
display_extenders: { }
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
display_extenders: { }
|
||||
path: test-node-revision-links
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Test D6NodeDeriver.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateNodeDeriverTest extends MigrateDrupal6TestBase {
|
||||
/**
|
||||
* The migration plugin manager.
|
||||
*
|
||||
* @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
|
||||
*/
|
||||
protected $pluginManager;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->pluginManager = $this->container->get('plugin.manager.migration');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test node translation migrations with translation disabled.
|
||||
*/
|
||||
public function testNoTranslations() {
|
||||
// Without content_translation, there should be no translation migrations.
|
||||
$migrations = $this->pluginManager->createInstances('d6_node_translation');
|
||||
$this->assertSame([], $migrations,
|
||||
"No node translation migrations without content_translation");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test node translation migrations with translation enabled.
|
||||
*/
|
||||
public function testTranslations() {
|
||||
// With content_translation, there should be translation migrations for
|
||||
// each content type.
|
||||
$this->enableModules(['language', 'content_translation']);
|
||||
$migrations = $this->pluginManager->createInstances('d6_node_translation');
|
||||
$this->assertArrayHasKey('d6_node_translation:story', $migrations,
|
||||
"Node translation migrations exist after content_translation installed");
|
||||
}
|
||||
|
||||
}
|
|
@ -16,6 +16,11 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
|
||||
use FileMigrationTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['language', 'content_translation'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -23,7 +28,7 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
parent::setUp();
|
||||
$this->setUpMigratedFiles();
|
||||
$this->installSchema('file', ['file_usage']);
|
||||
$this->executeMigrations(['d6_node']);
|
||||
$this->executeMigrations(['language', 'd6_node', 'd6_node_translation']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,6 +90,15 @@ class MigrateNodeTest extends MigrateNodeTestBase {
|
|||
$this->assertSame('Buy it now', $node->field_test_link->title);
|
||||
$this->assertSame(['attributes' => ['target' => '_blank']], $node->field_test_link->options);
|
||||
|
||||
// Test that translations are working.
|
||||
$node = Node::load(10);
|
||||
$this->assertIdentical('en', $node->langcode->value);
|
||||
$this->assertIdentical('The Real McCoy', $node->title->value);
|
||||
$this->assertTrue($node->hasTranslation('fr'), "Node 10 has french translation");
|
||||
|
||||
// Node 11 is a translation of node 10, and should not be imported separately.
|
||||
$this->assertNull(Node::load(11), "Node 11 doesn't exist in D8, it was a translation");
|
||||
|
||||
// Rerun migration with two source database changes.
|
||||
// 1. Add an invalid link attributes and a different URL and
|
||||
// title. If only the attributes are changed the error does not occur.
|
||||
|
|
|
@ -44,6 +44,7 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
|
|||
'd7_user',
|
||||
'd7_node_type',
|
||||
'd7_comment_type',
|
||||
'd7_taxonomy_vocabulary',
|
||||
'd7_field',
|
||||
'd7_field_instance',
|
||||
'd7_node:test_content_type',
|
||||
|
@ -139,9 +140,13 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
|
|||
$this->assertIdentical('title text', $node->field_images->title);
|
||||
$this->assertIdentical('93', $node->field_images->width);
|
||||
$this->assertIdentical('93', $node->field_images->height);
|
||||
$this->assertIdentical('http://google.com', $node->field_link->uri);
|
||||
$this->assertIdentical('Click Here', $node->field_link->title);
|
||||
|
||||
$node = Node::load(2);
|
||||
$this->assertIdentical("...is that it's the absolute best show ever. Trust me, I would know.", $node->body->value);
|
||||
$this->assertIdentical('internal:/', $node->field_link->uri);
|
||||
$this->assertIdentical('Home', $node->field_link->title);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class NodeByNodeTypeTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 1',
|
||||
|
@ -64,7 +64,7 @@ class NodeByNodeTypeTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 2,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
|
|
|
@ -134,7 +134,7 @@ class NodeRevisionByNodeTypeTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
'vid' => 1,
|
||||
'node_uid' => 1,
|
||||
|
@ -156,7 +156,7 @@ class NodeRevisionByNodeTypeTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
'vid' => 3,
|
||||
'node_uid' => 1,
|
||||
|
|
|
@ -133,7 +133,7 @@ class NodeRevisionTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'vid' => 1,
|
||||
|
@ -157,7 +157,7 @@ class NodeRevisionTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'vid' => 3,
|
||||
|
|
|
@ -2,16 +2,12 @@
|
|||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\Node';
|
||||
class NodeTest extends NodeTestBase {
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
|
@ -36,7 +32,7 @@ class NodeTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 1',
|
||||
|
@ -60,7 +56,7 @@ class NodeTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 2,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
|
@ -83,7 +79,7 @@ class NodeTest extends MigrateSqlSourceTestCase {
|
|||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'tnid' => 5,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 5',
|
||||
|
@ -98,79 +94,29 @@ class NodeTest extends MigrateSqlSourceTestCase {
|
|||
),
|
||||
),
|
||||
),
|
||||
array(
|
||||
'nid' => 6,
|
||||
'vid' => 6,
|
||||
'type' => 'story',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 6',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290909,
|
||||
'changed' => 1279308994,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 6,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 6',
|
||||
'teaser' => 'body for node 6',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308994,
|
||||
'format' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['content_node_field'] = array(
|
||||
array(
|
||||
'field_name' => 'field_test_four',
|
||||
'type' => 'number_float',
|
||||
'global_settings' => 'a:0:{}',
|
||||
'required' => '0',
|
||||
'multiple' => '0',
|
||||
'db_storage' => '1',
|
||||
'module' => 'number',
|
||||
'db_columns' => 'a:1:{s:5:"value";a:3:{s:4:"type";s:5:"float";s:8:"not null";b:0;s:8:"sortable";b:1;}}',
|
||||
'active' => '1',
|
||||
'locked' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['content_node_field_instance'] = array(
|
||||
array(
|
||||
'field_name' => 'field_test_four',
|
||||
'type_name' => 'story',
|
||||
'weight' => '3',
|
||||
'label' => 'Float Field',
|
||||
'widget_type' => 'number',
|
||||
'widget_settings' => 'a:0:{}',
|
||||
'display_settings' => 'a:0:{}',
|
||||
'description' => 'An example float field.',
|
||||
'widget_module' => 'number',
|
||||
'widget_active' => '1',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['content_type_story'] = array(
|
||||
array(
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'uid' => 5,
|
||||
'field_test_four_value' => '3.14159',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['system'] = array(
|
||||
array(
|
||||
'type' => 'module',
|
||||
'name' => 'content',
|
||||
'schema_version' => 6001,
|
||||
'status' => TRUE,
|
||||
),
|
||||
);
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
foreach (array('nid', 'vid', 'title', 'uid', 'body', 'teaser', 'format', 'timestamp', 'log') as $field) {
|
||||
$this->databaseContents['node_revisions'][$k][$field] = $row[$field];
|
||||
switch ($field) {
|
||||
case 'nid': case 'vid':
|
||||
break;
|
||||
case 'uid':
|
||||
$this->databaseContents['node_revisions'][$k]['uid']++;
|
||||
break;
|
||||
default:
|
||||
unset($row[$field]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->databaseContents['node'][$k] = $row;
|
||||
}
|
||||
array_walk($this->expectedResults, function (&$row) {
|
||||
$row['node_uid'] = $row['uid'];
|
||||
$row['revision_uid'] = $row['uid'] + 1;
|
||||
unset($row['uid']);
|
||||
});
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Base for D6 node migration tests.
|
||||
*/
|
||||
abstract class NodeTestBase extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\Node';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['content_node_field'] = array(
|
||||
array(
|
||||
'field_name' => 'field_test_four',
|
||||
'type' => 'number_float',
|
||||
'global_settings' => 'a:0:{}',
|
||||
'required' => '0',
|
||||
'multiple' => '0',
|
||||
'db_storage' => '1',
|
||||
'module' => 'number',
|
||||
'db_columns' => 'a:1:{s:5:"value";a:3:{s:4:"type";s:5:"float";s:8:"not null";b:0;s:8:"sortable";b:1;}}',
|
||||
'active' => '1',
|
||||
'locked' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['content_node_field_instance'] = array(
|
||||
array(
|
||||
'field_name' => 'field_test_four',
|
||||
'type_name' => 'story',
|
||||
'weight' => '3',
|
||||
'label' => 'Float Field',
|
||||
'widget_type' => 'number',
|
||||
'widget_settings' => 'a:0:{}',
|
||||
'display_settings' => 'a:0:{}',
|
||||
'description' => 'An example float field.',
|
||||
'widget_module' => 'number',
|
||||
'widget_active' => '1',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['content_type_story'] = array(
|
||||
array(
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'uid' => 5,
|
||||
'field_test_four_value' => '3.14159',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['system'] = array(
|
||||
array(
|
||||
'type' => 'module',
|
||||
'name' => 'content',
|
||||
'schema_version' => 6001,
|
||||
'status' => TRUE,
|
||||
),
|
||||
);
|
||||
$this->databaseContents['node'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'translate' => 0,
|
||||
'tnid' => 0,
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'translate' => 0,
|
||||
'tnid' => 0,
|
||||
],
|
||||
[
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'story',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'translate' => 0,
|
||||
'tnid' => 0,
|
||||
],
|
||||
[
|
||||
'nid' => 6,
|
||||
'vid' => 6,
|
||||
'type' => 'story',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 6',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290909,
|
||||
'changed' => 1279308994,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'translate' => 0,
|
||||
'tnid' => 6,
|
||||
],
|
||||
[
|
||||
'nid' => 7,
|
||||
'vid' => 7,
|
||||
'type' => 'story',
|
||||
'language' => 'fr',
|
||||
'title' => 'node title 7',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290910,
|
||||
'changed' => 1279308995,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'translate' => 0,
|
||||
'tnid' => 6,
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($this->databaseContents['node'] as $k => $row) {
|
||||
// Find the equivalent row from expected results.
|
||||
$result_row = NULL;
|
||||
foreach ($this->expectedResults as $result) {
|
||||
if (in_array($result['nid'], [$row['nid'], $row['tnid']]) && $result['language'] == $row['language']) {
|
||||
$result_row = $result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Populate node_revisions.
|
||||
foreach (array('nid', 'vid', 'title', 'uid', 'body', 'teaser', 'format', 'timestamp', 'log') as $field) {
|
||||
$value = isset($row[$field]) ? $row[$field] : $result_row[$field];
|
||||
$this->databaseContents['node_revisions'][$k][$field] = $value;
|
||||
if ($field == 'uid') {
|
||||
$this->databaseContents['node_revisions'][$k]['uid']++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
array_walk($this->expectedResults, function (&$row) {
|
||||
$row['node_uid'] = $row['uid'];
|
||||
$row['revision_uid'] = $row['uid'] + 1;
|
||||
unset($row['uid']);
|
||||
});
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Tests D6 node translation source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTranslationTest extends NodeTestBase {
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_node',
|
||||
'translations' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'nid' => 7,
|
||||
'vid' => 7,
|
||||
'type' => 'story',
|
||||
'language' => 'fr',
|
||||
'title' => 'node title 7',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290910,
|
||||
'changed' => 1279308995,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 6,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 7',
|
||||
'teaser' => 'body for node 7',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308995,
|
||||
'format' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
}
|
Reference in a new issue