Update to Drupal 8.2.2. For more information, see https://www.drupal.org/project/drupal/releases/8.2.2
This commit is contained in:
parent
23ffed3665
commit
507b45a0ed
378 changed files with 11434 additions and 5542 deletions
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 node source plugin with 'node_type' configuration.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d6\Node
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeByNodeTypeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['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,
|
||||
'tnid' => 1,
|
||||
'translate' => 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,
|
||||
'tnid' => 2,
|
||||
'translate' => 0,
|
||||
],
|
||||
// Add another row with an article node and make sure it is not migrated.
|
||||
[
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
$tests[0]['source_data']['node_revisions'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'title' => 'node title 1',
|
||||
'uid' => 2,
|
||||
'timestamp' => 1279051598,
|
||||
'body' => 'body for node 1',
|
||||
'teaser' => 'teaser for node 1',
|
||||
'format' => 1,
|
||||
'log' => 'log message 1',
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'title' => 'node title 2',
|
||||
'uid' => 2,
|
||||
'timestamp' => 1279290908,
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'format' => 1,
|
||||
'log' => 'log message 2',
|
||||
],
|
||||
// Add another row with an article node and make sure it is not migrated.
|
||||
[
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'title' => 'node title 5',
|
||||
'uid' => 2,
|
||||
'timestamp' => 1279290908,
|
||||
'body' => 'body for node 5',
|
||||
'teaser' => 'body for node 5',
|
||||
'format' => 1,
|
||||
'log' => 'log message 3',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'status' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 1',
|
||||
'teaser' => 'teaser for node 1',
|
||||
'format' => 1,
|
||||
'log' => 'log message 1',
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'status' => 1,
|
||||
'timestamp' => 1279290908,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 2,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'format' => 1,
|
||||
'log' => 'log message 2',
|
||||
],
|
||||
];
|
||||
|
||||
// Do an automatic count.
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
|
||||
// Set up source plugin configuration.
|
||||
$tests[0]['configuration'] = [
|
||||
'node_type' => 'page',
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 node revision source plugin.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d6\NodeRevision
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeRevisionByNodeTypeTest extends MigrateSqlSourceTestCase {
|
||||
class NodeRevisionByNodeTypeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\NodeRevision';
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
// The fake configuration for the source.
|
||||
'source' => [
|
||||
'plugin' => 'd6_node_revision',
|
||||
'node_type' => 'page',
|
||||
],
|
||||
'sourceIds' => [
|
||||
'vid' => [
|
||||
'alias' => 'v',
|
||||
],
|
||||
],
|
||||
'destinationIds' => [
|
||||
'vid' => [
|
||||
// This is where the field schema would go.
|
||||
],
|
||||
],
|
||||
];
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
protected $databaseContents = [
|
||||
'node' => [
|
||||
// The source data.
|
||||
$tests[0]['source_data']['node'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
|
@ -69,8 +60,8 @@ class NodeRevisionByNodeTypeTest extends MigrateSqlSourceTestCase {
|
|||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
],
|
||||
],
|
||||
'node_revisions' => [
|
||||
];
|
||||
$tests[0]['source_data']['node_revisions'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
|
@ -115,58 +106,69 @@ class NodeRevisionByNodeTypeTest extends MigrateSqlSourceTestCase {
|
|||
'format' => 1,
|
||||
'timestamp' => 1279308993,
|
||||
],
|
||||
],
|
||||
];
|
||||
];
|
||||
|
||||
// There are three revisions of nid 1; vid 4 is the current one. The
|
||||
// NodeRevision plugin should capture every revision EXCEPT that one.
|
||||
// nid 2 will be ignored because $this->migrationConfiguration specifies
|
||||
// a particular node type.
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
'vid' => 1,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
'body' => 'body for revision 1 (node 1)',
|
||||
'teaser' => 'teaser for revision 1 (node 1)',
|
||||
'log' => 'log for revision 1 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
'vid' => 3,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 3 (node 1)',
|
||||
'body' => 'body for revision 3 (node 1)',
|
||||
'teaser' => 'teaser for revision 3 (node 1)',
|
||||
'log' => 'log for revision 3 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
];
|
||||
// The expected results.
|
||||
// There are three revisions of nid 1; vid 4 is the current one. The
|
||||
// NodeRevision plugin should capture every revision EXCEPT that one.
|
||||
// nid 2 will be ignored because source plugin configuration specifies
|
||||
// a particular node type.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
'vid' => 1,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
'body' => 'body for revision 1 (node 1)',
|
||||
'teaser' => 'teaser for revision 1 (node 1)',
|
||||
'log' => 'log for revision 1 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
'vid' => 3,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 3 (node 1)',
|
||||
'body' => 'body for revision 3 (node 1)',
|
||||
'teaser' => 'teaser for revision 3 (node 1)',
|
||||
'log' => 'log for revision 3 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
// Do an automatic count.
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
|
||||
// Set up source plugin configuration.
|
||||
$tests[0]['configuration'] = [
|
||||
'node_type' => 'page',
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,39 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 node revision source plugin.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d6\NodeRevision
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeRevisionTest extends MigrateSqlSourceTestCase {
|
||||
class NodeRevisionTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\NodeRevision';
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
// The fake configuration for the source.
|
||||
'source' => [
|
||||
'plugin' => 'd6_node_revision',
|
||||
],
|
||||
'sourceIds' => [
|
||||
'vid' => [
|
||||
'alias' => 'v',
|
||||
],
|
||||
],
|
||||
'destinationIds' => [
|
||||
'vid' => [
|
||||
// This is where the field schema would go.
|
||||
],
|
||||
],
|
||||
];
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
protected $databaseContents = [
|
||||
'node' => [
|
||||
// The source data.
|
||||
$tests[0]['source_data']['node'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
|
@ -68,8 +60,8 @@ class NodeRevisionTest extends MigrateSqlSourceTestCase {
|
|||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
],
|
||||
],
|
||||
'node_revisions' => [
|
||||
];
|
||||
$tests[0]['source_data']['node_revisions'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
|
@ -114,61 +106,64 @@ class NodeRevisionTest extends MigrateSqlSourceTestCase {
|
|||
'format' => 1,
|
||||
'timestamp' => 1279308993,
|
||||
],
|
||||
],
|
||||
];
|
||||
];
|
||||
|
||||
// There are three revisions of nid 1, but the NodeRevision source ignores
|
||||
// the current revision. So only two revisions will be returned here. nid 2
|
||||
// is ignored because it only has one revision (the current one).
|
||||
protected $expectedResults = [
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'vid' => 1,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
'body' => 'body for revision 1 (node 1)',
|
||||
'teaser' => 'teaser for revision 1 (node 1)',
|
||||
'log' => 'log for revision 1 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'vid' => 3,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 3 (node 1)',
|
||||
'body' => 'body for revision 3 (node 1)',
|
||||
'teaser' => 'teaser for revision 3 (node 1)',
|
||||
'log' => 'log for revision 3 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
];
|
||||
// The expected results.
|
||||
// There are three revisions of nid 1, but the NodeRevision source ignores
|
||||
// the current revision. So only two revisions will be returned here. nid 2
|
||||
// is ignored because it only has one revision (the current one).
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'vid' => 1,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
'body' => 'body for revision 1 (node 1)',
|
||||
'teaser' => 'teaser for revision 1 (node 1)',
|
||||
'log' => 'log for revision 1 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'vid' => 3,
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 1,
|
||||
'title' => 'title for revision 3 (node 1)',
|
||||
'body' => 'body for revision 3 (node 1)',
|
||||
'teaser' => 'teaser for revision 3 (node 1)',
|
||||
'log' => 'log for revision 3 (node 1)',
|
||||
'format' => 1,
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,328 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 node source plugin.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d6\Node
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['content_node_field'] = [
|
||||
[
|
||||
'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',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['content_node_field_instance'] = [
|
||||
[
|
||||
'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',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['content_type_story'] = [
|
||||
[
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'uid' => 5,
|
||||
'field_test_four_value' => '3.14159',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['system'] = [
|
||||
[
|
||||
'type' => 'module',
|
||||
'name' => 'content',
|
||||
'schema_version' => 6001,
|
||||
'status' => TRUE,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['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,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['node_revisions'] = [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'uid' => 2,
|
||||
'title' => 'node title 1',
|
||||
'body' => 'body for node 1',
|
||||
'teaser' => 'teaser for node 1',
|
||||
'log' => '',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'uid' => 2,
|
||||
'title' => 'node title 2',
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'log' => '',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279308993,
|
||||
],
|
||||
[
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'uid' => 2,
|
||||
'title' => 'node title 5',
|
||||
'body' => 'body for node 5',
|
||||
'teaser' => 'body for node 5',
|
||||
'log' => '',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279308993,
|
||||
],
|
||||
[
|
||||
'nid' => 6,
|
||||
'vid' => 6,
|
||||
'uid' => 2,
|
||||
'title' => 'node title 6',
|
||||
'body' => 'body for node 6',
|
||||
'teaser' => 'body for node 6',
|
||||
'log' => '',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279308994,
|
||||
],
|
||||
[
|
||||
'nid' => 7,
|
||||
'vid' => 7,
|
||||
'uid' => 2,
|
||||
'title' => 'node title 7',
|
||||
'body' => 'body for node 7',
|
||||
'teaser' => 'body for node 7',
|
||||
'log' => '',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279308995,
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 1',
|
||||
'teaser' => 'teaser for node 1',
|
||||
'log' => '',
|
||||
'timestamp' => 1279051598,
|
||||
'format' => 1,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 2,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'format' => 1,
|
||||
],
|
||||
[
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'story',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 5,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 5',
|
||||
'teaser' => 'body for node 5',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'format' => 1,
|
||||
'field_test_four' => [
|
||||
[
|
||||
'value' => '3.14159',
|
||||
'delta' => 0,
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
'nid' => 6,
|
||||
'vid' => 6,
|
||||
'type' => 'story',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 6',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'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,
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Tests D6 node translation source plugin.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d6\Node
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTranslationTest extends NodeTest {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
// Get the source data from parent.
|
||||
$tests = parent::providerSource();
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'nid' => 7,
|
||||
'vid' => 7,
|
||||
'type' => 'story',
|
||||
'language' => 'fr',
|
||||
'title' => 'node title 7',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'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,
|
||||
],
|
||||
];
|
||||
|
||||
// Do an automatic count.
|
||||
$tests[0]['expected_count'] = NULL;
|
||||
|
||||
// Set up source plugin configuration.
|
||||
$tests[0]['configuration'] = [
|
||||
'translations' => TRUE,
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 node type source plugin.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d6\NodeType
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTypeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['node_type'] = [
|
||||
[
|
||||
'type' => 'page',
|
||||
'name' => 'Page',
|
||||
'module' => 'node',
|
||||
'description' => 'A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'has_body' => 1,
|
||||
'body_label' => 'Body',
|
||||
'min_word_count' => 0,
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'orig_type' => 'page',
|
||||
],
|
||||
[
|
||||
'type' => 'story',
|
||||
'name' => 'Story',
|
||||
'module' => 'node',
|
||||
'description' => 'A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'has_body' => 1,
|
||||
'body_label' => 'Body',
|
||||
'min_word_count' => 0,
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'orig_type' => 'story',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = $tests[0]['source_data']['node_type'];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D6 view mode source plugin.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d6\ViewMode
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class ViewModeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['content_node_field_instance'] = [
|
||||
[
|
||||
'display_settings' => serialize([
|
||||
'weight' => '31',
|
||||
'parent' => '',
|
||||
'label' => [
|
||||
'format' => 'above',
|
||||
],
|
||||
'teaser' => [
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
],
|
||||
'full' => [
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
],
|
||||
4 => [
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
],
|
||||
]),
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => '4',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'teaser',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'full',
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,232 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 node source plugin.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d7\Node
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['node'] = [
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
],
|
||||
|
||||
];
|
||||
$tests[0]['source_data']['node_revision'] = [
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'uid' => 2,
|
||||
'title' => 'node title 1',
|
||||
'log' => '',
|
||||
'timestamp' => 1279051598,
|
||||
'status' => 1,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'uid' => 2,
|
||||
'title' => 'node title 2',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'status' => 1,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'uid' => 2,
|
||||
'title' => 'node title 5',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'status' => 1,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'id' => '2',
|
||||
'field_id' => '2',
|
||||
'field_name' => 'body',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
],
|
||||
[
|
||||
'id' => '2',
|
||||
'field_id' => '2',
|
||||
'field_name' => 'body',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_revision_body'] = [
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'en',
|
||||
'delta' => '0',
|
||||
'body_value' => 'Foobaz',
|
||||
'body_summary' => '',
|
||||
'body_format' => 'filtered_html',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = [
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'log' => '',
|
||||
'timestamp' => 1279051598,
|
||||
'body' => [
|
||||
[
|
||||
'value' => 'Foobaz',
|
||||
'summary' => '',
|
||||
'format' => 'filtered_html',
|
||||
],
|
||||
],
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
],
|
||||
[
|
||||
// Node fields.
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'node_uid' => 1,
|
||||
'revision_uid' => 2,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
],
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Kernel\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
||||
|
||||
/**
|
||||
* Tests D7 node type source plugin.
|
||||
*
|
||||
* @covers \Drupal\node\Plugin\migrate\source\d7\NodeType
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTypeTest extends MigrateSqlSourceTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'user', 'migrate_drupal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function providerSource() {
|
||||
$tests = [];
|
||||
|
||||
// The source data.
|
||||
$tests[0]['source_data']['node_type'] = [
|
||||
[
|
||||
'type' => 'page',
|
||||
'name' => 'Page',
|
||||
'base' => 'node',
|
||||
'description' => 'A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'disabled' => 0,
|
||||
'orig_type' => 'page',
|
||||
],
|
||||
[
|
||||
'type' => 'story',
|
||||
'name' => 'Story',
|
||||
'base' => 'node',
|
||||
'description' => 'A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'disabled' => 0,
|
||||
'orig_type' => 'story',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['variable'] = [
|
||||
[
|
||||
'name' => 'node_options_page',
|
||||
'value' => 'a:1:{i:0;s:6:"status";}',
|
||||
],
|
||||
[
|
||||
'name' => 'node_options_story',
|
||||
'value' => 'a:1:{i:0;s:6:"status";}',
|
||||
],
|
||||
];
|
||||
$tests[0]['source_data']['field_config_instance'] = [
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'field_name' => 'body',
|
||||
'data' => 'a:1:{s:5:"label";s:4:"Body";}',
|
||||
],
|
||||
[
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'story',
|
||||
'field_name' => 'body',
|
||||
'data' => 'a:1:{s:5:"label";s:4:"Body";}',
|
||||
],
|
||||
];
|
||||
|
||||
// The expected results.
|
||||
$tests[0]['expected_data'] = $tests[0]['source_data']['node_type'];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node source plugin with 'node_type' configuration.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeByNodeTypeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\Node';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
// The fake configuration for the source.
|
||||
'source' => array(
|
||||
'plugin' => 'd6_node',
|
||||
'node_type' => 'page',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 1',
|
||||
'teaser' => 'teaser for node 1',
|
||||
'format' => 1,
|
||||
'log' => 'log message 1',
|
||||
),
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'timestamp' => 1279290908,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 2,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'format' => 1,
|
||||
'log' => 'log message 2',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$database_contents = $this->expectedResults;
|
||||
array_walk($this->expectedResults, function (&$row) {
|
||||
$row['node_uid'] = $row['uid'];
|
||||
$row['revision_uid'] = $row['uid'] + 1;
|
||||
unset($row['uid']);
|
||||
});
|
||||
|
||||
$database_contents[] = array(
|
||||
// Node fields.
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'timestamp' => 1279290908,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 5',
|
||||
'teaser' => 'body for node 5',
|
||||
'format' => 1,
|
||||
'log' => 'log message 3',
|
||||
);
|
||||
|
||||
// Add another row with an article node and make sure it is not migrated.
|
||||
|
||||
foreach ($database_contents 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;
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
/**
|
||||
* Tests D6 node source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTest extends NodeTestBase {
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_node',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
// Node fields.
|
||||
'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,
|
||||
'tnid' => 1,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 1',
|
||||
'teaser' => 'teaser for node 1',
|
||||
'log' => '',
|
||||
'timestamp' => 1279051598,
|
||||
'format' => 1,
|
||||
),
|
||||
array(
|
||||
// Node fields.
|
||||
'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,
|
||||
'tnid' => 2,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'format' => 1,
|
||||
),
|
||||
array(
|
||||
'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,
|
||||
'tnid' => 5,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 5',
|
||||
'teaser' => 'body for node 5',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'format' => 1,
|
||||
'field_test_four' => array(
|
||||
array(
|
||||
'value' => '3.14159',
|
||||
'delta' => 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
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,
|
||||
),
|
||||
);
|
||||
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
<?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();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
<?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,
|
||||
),
|
||||
);
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node type source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTypeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\NodeType';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'test_nodetypes',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_nodetype',
|
||||
),
|
||||
);
|
||||
|
||||
// We need to set up the database contents; it's easier to do that below.
|
||||
// These are sample result queries.
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'type' => 'page',
|
||||
'name' => 'Page',
|
||||
'module' => 'node',
|
||||
'description' => 'A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'has_body' => 1,
|
||||
'body_label' => 'Body',
|
||||
'min_word_count' => 0,
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'orig_type' => 'page',
|
||||
),
|
||||
array(
|
||||
'type' => 'story',
|
||||
'name' => 'Story',
|
||||
'module' => 'node',
|
||||
'description' => 'A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'has_body' => 1,
|
||||
'body_label' => 'Body',
|
||||
'min_word_count' => 0,
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'orig_type' => 'story',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 view mode source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class ViewModeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
// The plugin system is not working during unit testing so the source plugin
|
||||
// class needs to be manually specified.
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\ViewMode';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
// The ID of the entity, can be any string.
|
||||
'id' => 'view_mode_test',
|
||||
'source' => array(
|
||||
'plugin' => 'd6_field_instance_view_mode',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => '4',
|
||||
),
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'teaser',
|
||||
),
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'view_mode' => 'full',
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
|
||||
$this->databaseContents['content_node_field_instance'][] = array(
|
||||
'display_settings' => serialize(array(
|
||||
'weight' => '31',
|
||||
'parent' => '',
|
||||
'label' => array(
|
||||
'format' => 'above',
|
||||
),
|
||||
'teaser' => array(
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
),
|
||||
'full' => array(
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
),
|
||||
4 => array(
|
||||
'format' => 'default',
|
||||
'exclude' => 0,
|
||||
),
|
||||
)),
|
||||
);
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 node source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d7\Node';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
'source' => array(
|
||||
'plugin' => 'd7_node',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 1',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'log' => '',
|
||||
'timestamp' => 1279051598,
|
||||
),
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 2',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
),
|
||||
array(
|
||||
// Node fields.
|
||||
'nid' => 5,
|
||||
'vid' => 5,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'title' => 'node title 5',
|
||||
'uid' => 1,
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
foreach ($this->expectedResults as $k => $row) {
|
||||
foreach (array('nid', 'vid', 'title', 'uid', 'timestamp', 'log') as $field) {
|
||||
$this->databaseContents['node_revision'][$k][$field] = $row[$field];
|
||||
switch ($field) {
|
||||
case 'nid': case 'vid':
|
||||
break;
|
||||
case 'uid':
|
||||
$this->databaseContents['node_revision'][$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']);
|
||||
});
|
||||
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
'id' => '2',
|
||||
'field_id' => '2',
|
||||
'field_name' => 'body',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
),
|
||||
array(
|
||||
'id' => '2',
|
||||
'field_id' => '2',
|
||||
'field_name' => 'body',
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'article',
|
||||
'data' => 'a:0:{}',
|
||||
'deleted' => '0',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_revision_body'] = array(
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'deleted' => '0',
|
||||
'entity_id' => '1',
|
||||
'revision_id' => '1',
|
||||
'language' => 'en',
|
||||
'delta' => '0',
|
||||
'body_value' => 'Foobaz',
|
||||
'body_summary' => '',
|
||||
'body_format' => 'filtered_html',
|
||||
),
|
||||
);
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 node type source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeTypeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d7\NodeType';
|
||||
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test_nodetypes',
|
||||
'source' => array(
|
||||
'plugin' => 'd7_node_type',
|
||||
),
|
||||
);
|
||||
|
||||
protected $expectedResults = array(
|
||||
array(
|
||||
'type' => 'page',
|
||||
'name' => 'Page',
|
||||
'base' => 'node',
|
||||
'description' => 'A <em>page</em>, similar in form to a <em>story</em>, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a <em>page</em> entry does not allow visitor comments and is not featured on the site\'s initial home page.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'disabled' => 0,
|
||||
'orig_type' => 'page',
|
||||
),
|
||||
array(
|
||||
'type' => 'story',
|
||||
'name' => 'Story',
|
||||
'base' => 'node',
|
||||
'description' => 'A <em>story</em>, similar in form to a <em>page</em>, is ideal for creating and displaying content that informs or engages website visitors. Press releases, site announcements, and informal blog-like entries may all be created with a <em>story</em> entry. By default, a <em>story</em> entry is automatically featured on the site\'s initial home page, and provides the ability to post comments.',
|
||||
'help' => '',
|
||||
'title_label' => 'Title',
|
||||
'custom' => 1,
|
||||
'modified' => 0,
|
||||
'locked' => 0,
|
||||
'disabled' => 0,
|
||||
'orig_type' => 'story',
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* Prepopulate contents with results.
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['node_type'] = $this->expectedResults;
|
||||
$this->databaseContents['variable'] = array(
|
||||
array(
|
||||
'name' => 'node_options_page',
|
||||
'value' => 'a:1:{i:0;s:6:"status";}',
|
||||
),
|
||||
array(
|
||||
'name' => 'node_options_story',
|
||||
'value' => 'a:1:{i:0;s:6:"status";}',
|
||||
),
|
||||
);
|
||||
$this->databaseContents['field_config_instance'] = array(
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'page',
|
||||
'field_name' => 'body',
|
||||
'data' => 'a:1:{s:5:"label";s:4:"Body";}',
|
||||
),
|
||||
array(
|
||||
'entity_type' => 'node',
|
||||
'bundle' => 'story',
|
||||
'field_name' => 'body',
|
||||
'data' => 'a:1:{s:5:"label";s:4:"Body";}',
|
||||
)
|
||||
);
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue