Update to Drupal 8.0.0 beta 14. For more information, see https://drupal.org/node/2544542
This commit is contained in:
parent
3b2511d96d
commit
81ccda77eb
2155 changed files with 54307 additions and 46870 deletions
|
@ -170,6 +170,7 @@ function node_test_node_insert(NodeInterface $node) {
|
|||
// Set the node title to the node ID and save.
|
||||
if ($node->getTitle() == 'new') {
|
||||
$node->setTitle('Node '. $node->id());
|
||||
$node->setNewRevision(FALSE);
|
||||
$node->save();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,142 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\node\Unit\Plugin\migrate\source\d6\NodeByNodeTypeTest.
|
||||
*/
|
||||
|
||||
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',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// 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' => 0,
|
||||
'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' => 0,
|
||||
'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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\node\Unit\Plugin\migrate\source\d6\NodeRevisionByNodeTypeTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node revision source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeRevisionByNodeTypeTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\NodeRevision';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => [],
|
||||
// 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.
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
protected $databaseContents = [
|
||||
'node' => [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 4,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 4 (node 1)',
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 2,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
],
|
||||
],
|
||||
'node_revisions' => [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'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,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 3,
|
||||
'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,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 4,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 4 (node 1)',
|
||||
'body' => 'body for revision 4 (node 1)',
|
||||
'teaser' => 'teaser for revision 4 (node 1)',
|
||||
'log' => 'log for revision 4 (node 1)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
'body' => 'body for revision 2 (node 2)',
|
||||
'teaser' => 'teaser for revision 2 (node 2)',
|
||||
'log' => 'log for revision 2 (node 2)',
|
||||
'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' => 0,
|
||||
'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' => 0,
|
||||
'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,
|
||||
],
|
||||
];
|
||||
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\node\Unit\Plugin\migrate\source\d6\NodeRevisionTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D6 node revision source plugin.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeRevisionTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\node\Plugin\migrate\source\d6\NodeRevision';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => [],
|
||||
// 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.
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
protected $databaseContents = [
|
||||
'node' => [
|
||||
[
|
||||
'nid' => 1,
|
||||
'type' => 'page',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279051598,
|
||||
'changed' => 1279051598,
|
||||
'comment' => 2,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 4,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 1 (node 1)',
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'type' => 'article',
|
||||
'language' => 'en',
|
||||
'status' => 1,
|
||||
'created' => 1279290908,
|
||||
'changed' => 1279308993,
|
||||
'comment' => 0,
|
||||
'promote' => 1,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
'vid' => 2,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
],
|
||||
],
|
||||
'node_revisions' => [
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 1,
|
||||
'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,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 3,
|
||||
'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,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 1,
|
||||
'vid' => 4,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 4 (node 1)',
|
||||
'body' => 'body for revision 4 (node 1)',
|
||||
'teaser' => 'teaser for revision 4 (node 1)',
|
||||
'log' => 'log for revision 4 (node 1)',
|
||||
'format' => 1,
|
||||
'timestamp' => 1279051598,
|
||||
],
|
||||
[
|
||||
'nid' => 2,
|
||||
'vid' => 2,
|
||||
'uid' => 1,
|
||||
'title' => 'title for revision 2 (node 2)',
|
||||
'body' => 'body for revision 2 (node 2)',
|
||||
'teaser' => 'teaser for revision 2 (node 2)',
|
||||
'log' => 'log for revision 2 (node 2)',
|
||||
'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' => 0,
|
||||
'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' => 0,
|
||||
'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,
|
||||
],
|
||||
];
|
||||
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\node\Unit\Plugin\migrate\source\d6\NodeTest.
|
||||
*/
|
||||
|
||||
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';
|
||||
|
||||
// The fake Migration configuration entity.
|
||||
protected $migrationConfiguration = array(
|
||||
'id' => 'test',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
// The fake configuration for the source.
|
||||
'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' => 0,
|
||||
'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' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 2',
|
||||
'teaser' => 'teaser for node 2',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'format' => 1,
|
||||
),
|
||||
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,
|
||||
'moderate' => 0,
|
||||
'sticky' => 0,
|
||||
'tnid' => 0,
|
||||
'translate' => 0,
|
||||
// Node revision fields.
|
||||
'body' => 'body for node 5',
|
||||
'teaser' => 'body for node 5',
|
||||
'log' => '',
|
||||
'timestamp' => 1279308993,
|
||||
'format' => 1,
|
||||
),
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
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,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\node\Unit\Plugin\migrate\source\d6\NodeTypeTest.
|
||||
*/
|
||||
|
||||
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',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'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();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\node\Unit\Plugin\migrate\source\d6\ViewModeTest.
|
||||
*/
|
||||
|
||||
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',
|
||||
// Leave it empty for now.
|
||||
'idlist' => array(),
|
||||
'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();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue