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:
Pantheon Automation 2016-08-03 13:22:33 -07:00 committed by Greg Anderson
parent e9f047ccf8
commit f9f23cdf38
312 changed files with 6751 additions and 1546 deletions

View file

@ -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");
}
}

View file

@ -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.

View file

@ -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);
}
}

View file

@ -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',

View file

@ -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,

View file

@ -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,

View file

@ -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();
}
}

View file

@ -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();
}
}

View file

@ -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,
),
);
}