updated core
This commit is contained in:
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
@@ -152,6 +152,12 @@ function node_access_test_node_access(NodeInterface $node, $op, AccountInterface
|
||||
// Make all Catalan content secret.
|
||||
return AccessResult::forbidden()->setCacheMaxAge(0);
|
||||
}
|
||||
|
||||
// Grant access if a specific user is specified.
|
||||
if (\Drupal::state()->get('node_access_test.allow_uid') === $account->id()) {
|
||||
return AccessResult::allowed();
|
||||
}
|
||||
|
||||
// No opinion.
|
||||
return AccessResult::neutral()->setCacheMaxAge(0);
|
||||
}
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
+3
-3
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- options
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
@@ -5,8 +5,8 @@ description: 'Support module for node configuration tests.'
|
||||
package: Testing
|
||||
# version: VERSION
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
@@ -9,8 +9,8 @@ dependencies:
|
||||
- views
|
||||
- language
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
+3
-3
@@ -5,8 +5,8 @@ package: Testing
|
||||
# version: VERSION
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-03
|
||||
version: '8.4.2'
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1509719929
|
||||
datestamp: 1515021228
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\node\Functional;
|
||||
|
||||
/**
|
||||
* Tests all the different buttons on the node form.
|
||||
*
|
||||
* @group node
|
||||
*/
|
||||
class NodeFormButtonsTest extends NodeTestBase {
|
||||
|
||||
use AssertButtonsTrait;
|
||||
|
||||
/**
|
||||
* A normal logged in user.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $webUser;
|
||||
|
||||
/**
|
||||
* A user with permission to bypass access content.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create a user that has no access to change the state of the node.
|
||||
$this->webUser = $this->drupalCreateUser(['create article content', 'edit own article content']);
|
||||
// Create a user that has access to change the state of the node.
|
||||
$this->adminUser = $this->drupalCreateUser(['administer nodes', 'bypass node access']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the right buttons are displayed for saving nodes.
|
||||
*/
|
||||
public function testNodeFormButtons() {
|
||||
$node_storage = $this->container->get('entity.manager')->getStorage('node');
|
||||
// Log in as administrative user.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Verify the buttons on a node add form.
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertButtons([t('Save and publish'), t('Save as unpublished')]);
|
||||
|
||||
// Save the node and assert it's published after clicking
|
||||
// 'Save and publish'.
|
||||
$edit = ['title[0][value]' => $this->randomString()];
|
||||
$this->drupalPostForm('node/add/article', $edit, t('Save and publish'));
|
||||
|
||||
// Get the node.
|
||||
$node_1 = $node_storage->load(1);
|
||||
$this->assertTrue($node_1->isPublished(), 'Node is published');
|
||||
|
||||
// Verify the buttons on a node edit form.
|
||||
$this->drupalGet('node/' . $node_1->id() . '/edit');
|
||||
$this->assertButtons([t('Save and keep published'), t('Save and unpublish')]);
|
||||
|
||||
// Save the node and verify it's still published after clicking
|
||||
// 'Save and keep published'.
|
||||
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
|
||||
$node_storage->resetCache([1]);
|
||||
$node_1 = $node_storage->load(1);
|
||||
$this->assertTrue($node_1->isPublished(), 'Node is published');
|
||||
|
||||
// Save the node and verify it's unpublished after clicking
|
||||
// 'Save and unpublish'.
|
||||
$this->drupalPostForm('node/' . $node_1->id() . '/edit', $edit, t('Save and unpublish'));
|
||||
$node_storage->resetCache([1]);
|
||||
$node_1 = $node_storage->load(1);
|
||||
$this->assertFalse($node_1->isPublished(), 'Node is unpublished');
|
||||
|
||||
// Verify the buttons on an unpublished node edit screen.
|
||||
$this->drupalGet('node/' . $node_1->id() . '/edit');
|
||||
$this->assertButtons([t('Save and keep unpublished'), t('Save and publish')]);
|
||||
|
||||
// Create a node as a normal user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalLogin($this->webUser);
|
||||
|
||||
// Verify the buttons for a normal user.
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertButtons([t('Save')], FALSE);
|
||||
|
||||
// Create the node.
|
||||
$edit = ['title[0][value]' => $this->randomString()];
|
||||
$this->drupalPostForm('node/add/article', $edit, t('Save'));
|
||||
$node_2 = $node_storage->load(2);
|
||||
$this->assertTrue($node_2->isPublished(), 'Node is published');
|
||||
|
||||
// Log in as an administrator and unpublish the node that just
|
||||
// was created by the normal user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalPostForm('node/' . $node_2->id() . '/edit', [], t('Save and unpublish'));
|
||||
$node_storage->resetCache([2]);
|
||||
$node_2 = $node_storage->load(2);
|
||||
$this->assertFalse($node_2->isPublished(), 'Node is unpublished');
|
||||
|
||||
// Log in again as the normal user, save the node and verify
|
||||
// it's still unpublished.
|
||||
$this->drupalLogout();
|
||||
$this->drupalLogin($this->webUser);
|
||||
$this->drupalPostForm('node/' . $node_2->id() . '/edit', [], t('Save'));
|
||||
$node_storage->resetCache([2]);
|
||||
$node_2 = $node_storage->load(2);
|
||||
$this->assertFalse($node_2->isPublished(), 'Node is still unpublished');
|
||||
$this->drupalLogout();
|
||||
|
||||
// Set article content type default to unpublished. This will change the
|
||||
// the initial order of buttons and/or status of the node when creating
|
||||
// a node.
|
||||
$fields = \Drupal::entityManager()->getFieldDefinitions('node', 'article');
|
||||
$fields['status']->getConfig('article')
|
||||
->setDefaultValue(FALSE)
|
||||
->save();
|
||||
|
||||
// Verify the buttons on a node add form for an administrator.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalGet('node/add/article');
|
||||
$this->assertButtons([t('Save as unpublished'), t('Save and publish')]);
|
||||
|
||||
// Verify the node is unpublished by default for a normal user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalLogin($this->webUser);
|
||||
$edit = ['title[0][value]' => $this->randomString()];
|
||||
$this->drupalPostForm('node/add/article', $edit, t('Save'));
|
||||
$node_3 = $node_storage->load(3);
|
||||
$this->assertFalse($node_3->isPublished(), 'Node is unpublished');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
-172
@@ -1,172 +0,0 @@
|
||||
<?php
|
||||
|
||||
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',
|
||||
// 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' => 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,
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
<?php
|
||||
|
||||
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',
|
||||
// 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' => 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,
|
||||
],
|
||||
];
|
||||
|
||||
}
|
||||
@@ -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 New Issue
Block a user