upgrades core to 8.4.2

This commit is contained in:
Bachir Soussi Chiadmi
2017-11-14 16:09:54 +01:00
parent bd60eff9b3
commit c2b4e25be4
3504 changed files with 140306 additions and 38684 deletions
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- options
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -14,7 +14,6 @@ use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
/**
* Implements hook_ENTITY_TYPE_view() for node entities.
*/
@@ -156,7 +155,7 @@ function node_test_node_update(NodeInterface $node) {
*/
function node_test_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) {
// Only alter the view mode if we are on the test callback.
$change_view_mode = \Drupal::state()->get( 'node_test_change_view_mode') ?: '';
$change_view_mode = \Drupal::state()->get('node_test_change_view_mode') ?: '';
if ($change_view_mode) {
$view_mode = $change_view_mode;
}
@@ -5,8 +5,8 @@ description: 'Support module for node configuration tests.'
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -9,8 +9,8 @@ dependencies:
- views
- language
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-08-16
version: '8.3.7'
# Information added by Drupal.org packaging script on 2017-11-03
version: '8.4.2'
core: '8.x'
project: 'drupal'
datestamp: 1502903957
datestamp: 1509719929
@@ -1,6 +1,7 @@
<?php
namespace Drupal\Tests\node\Functional\Migrate\d6;
use Drupal\Tests\node\Kernel\Migrate\d6\MigrateNodeTestBase;
/**
@@ -1,6 +1,7 @@
<?php
namespace Drupal\Tests\node\Functional;
use Drupal\Component\Utility\Unicode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
@@ -3,7 +3,7 @@
namespace Drupal\Tests\node\Functional;
use Drupal\Core\Url;
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
/**
* Tests the node access automatic cacheability bubbling logic.
@@ -114,7 +114,7 @@ class NodeAccessBaseTableTest extends NodeTestBase {
$this->drupalPostForm('node/add/article', $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertEqual($is_private, (int)$node->private->value, 'The private status of the node was properly set in the node_access_test table.');
$this->assertEqual($is_private, (int) $node->private->value, 'The private status of the node was properly set in the node_access_test table.');
if ($is_private) {
$private_nodes[] = $node->id();
}
@@ -1,6 +1,7 @@
<?php
namespace Drupal\Tests\node\Functional;
use Drupal\Component\Utility\Unicode;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
@@ -4,7 +4,7 @@ namespace Drupal\Tests\node\Functional;
use Drupal\block\Entity\Block;
use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
use Drupal\Tests\system\Functional\Cache\AssertPageCacheContextsAndTagsTrait;
use Drupal\user\RoleInterface;
/**
@@ -184,7 +184,7 @@ class NodeCreationTest extends NodeTestBase {
$this->assertNoLinkByHref('/admin/structure/types/add');
// Test /node/add page without content types.
foreach (\Drupal::entityManager()->getStorage('node_type')->loadMultiple() as $entity ) {
foreach (\Drupal::entityManager()->getStorage('node_type')->loadMultiple() as $entity) {
$entity->delete();
}
@@ -98,7 +98,7 @@ class NodeEditFormTest extends NodeTestBase {
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
$edit['revision'] = TRUE;
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
$this->drupalPostForm(NULL, $edit, t('Save'));
// Ensure that the node revision has been created.
$revised_node = $this->drupalGetNodeByTitle($edit['title[0][value]'], TRUE);
@@ -124,12 +124,21 @@ class NodeEditFormTest extends NodeTestBase {
$edit['created[0][value][date]'] = $this->randomMachineName(8);
// Get the current amount of open details elements.
$open_details_elements = count($this->cssSelect('details[open="open"]'));
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
$this->drupalPostForm(NULL, $edit, t('Save'));
// The node author details must be open.
$this->assertRaw('<details class="node-form-author js-form-wrapper form-wrapper" data-drupal-selector="edit-author" id="edit-author" open="open">');
// Only one extra details element should now be open.
$open_details_elements++;
$this->assertEqual(count($this->cssSelect('details[open="open"]')), $open_details_elements, 'Exactly one extra open &lt;details&gt; element found.');
// Edit the same node, save it and verify it's unpublished after unchecking
// the 'Published' boolean_checkbox and clicking 'Save'.
$this->drupalGet("node/" . $node->id() . "/edit");
$edit = ['status[value]' => FALSE];
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$this->assertFalse($node->isPublished(), 'Node is unpublished');
}
/**
@@ -143,7 +152,7 @@ class NodeEditFormTest extends NodeTestBase {
$edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit[$body_key] = $this->randomMachineName(16);
$this->drupalPostForm('node/add/page', $edit, t('Save and publish'));
$this->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the node was authored by the currently logged in user.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
@@ -172,7 +181,7 @@ class NodeEditFormTest extends NodeTestBase {
$this->drupalLogin($this->adminUser);
// Save the node without making any changes.
$this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and keep published'));
$this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save'));
$this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$this->assertIdentical($this->webUser->id(), $node->getOwner()->id());
@@ -184,12 +193,49 @@ class NodeEditFormTest extends NodeTestBase {
// Check that saving the node without making any changes keeps the proper
// author ID.
$this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save and keep published'));
$this->drupalPostForm('node/' . $node->id() . '/edit', [], t('Save'));
$this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$this->assertIdentical($this->webUser->id(), $node->getOwner()->id());
}
/**
* Tests the node meta information.
*/
public function testNodeMetaInformation() {
// Check that regular users (i.e. without the 'administer nodes' permission)
// can not see the meta information.
$this->drupalLogin($this->webUser);
$this->drupalGet('node/add/page');
$this->assertNoText('Not saved yet');
// Create node to edit.
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->drupalGet("node/" . $node->id() . "/edit");
$this->assertNoText('Published');
$this->assertNoText(format_date($node->getChangedTime(), 'short'));
// Check that users with the 'administer nodes' permission can see the meta
// information.
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/add/page');
$this->assertText('Not saved yet');
// Create node to edit.
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalPostForm(NULL, $edit, t('Save'));
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->drupalGet("node/" . $node->id() . "/edit");
$this->assertText('Published');
$this->assertText(format_date($node->getChangedTime(), 'short'));
}
/**
* Checks that the "authored by" works correctly with various values.
*
@@ -203,13 +249,13 @@ class NodeEditFormTest extends NodeTestBase {
$edit = [
$form_element_name => 'invalid-name',
];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->assertRaw(t('There are no entities matching "%name".', ['%name' => 'invalid-name']));
// Change the authored by field to an empty string, which should assign
// authorship to the anonymous user (uid 0).
$edit[$form_element_name] = '';
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$uid = $node->getOwnerId();
@@ -228,7 +274,7 @@ class NodeEditFormTest extends NodeTestBase {
// Change the authored by field to another user's name (that is not
// logged in).
$edit[$form_element_name] = $this->webUser->getUsername();
$this->drupalPostForm(NULL, $edit, t('Save and keep published'));
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->nodeStorage->resetCache([$node->id()]);
$node = $this->nodeStorage->load($node->id());
$this->assertIdentical($node->getOwnerId(), $this->webUser->id(), 'Node authored by normal user.');
@@ -67,7 +67,7 @@ class NodeRevisionsUiBypassAccessTest extends NodeTestBase {
// Uncheck the create new revision checkbox and save the node.
$edit = ['revision' => FALSE];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save and keep published');
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save');
$this->assertUrl($node->toUrl());
$this->assertNoLink(t('Revisions'));
@@ -78,7 +78,7 @@ class NodeRevisionsUiBypassAccessTest extends NodeTestBase {
// Submit the form without changing the checkbox.
$edit = [];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save and keep published');
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, 'Save');
$this->assertUrl($node->toUrl());
$this->assertLink(t('Revisions'));
@@ -55,7 +55,7 @@ class NodeRevisionsUiTest extends NodeTestBase {
// Uncheck the create new revision checkbox and save the node.
$edit = ['revision' => FALSE];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Load the node again and check the revision is the same as before.
$node_storage->resetCache([$node->id()]);
@@ -68,7 +68,7 @@ class NodeRevisionsUiTest extends NodeTestBase {
// Submit the form without changing the checkbox.
$edit = [];
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Load the node again and check the revision is different from before.
$node_storage->resetCache([$node->id()]);
@@ -109,8 +109,10 @@ class NodeSaveTest extends NodeTestBase {
'uid' => $this->webUser->id(),
'type' => 'article',
'title' => $this->randomMachineName(8),
'created' => 280299600, // Sun, 19 Nov 1978 05:00:00 GMT
'changed' => 979534800, // Drupal 1.0 release.
// Sun, 19 Nov 1978 05:00:00 GMT.
'created' => 280299600,
// Drupal 1.0 release.
'changed' => 979534800,
];
Node::create($edit)->save();
@@ -99,7 +99,9 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
'source' => $default_langcode,
'target' => $langcode
], ['language' => $language]);
$this->drupalPostForm($add_url, $this->getEditValues($values, $langcode), t('Save and unpublish (this translation)'));
$edit = $this->getEditValues($values, $langcode);
$edit['status[value]'] = FALSE;
$this->drupalPostForm($add_url, $edit, t('Save (this translation)'));
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
@@ -136,18 +138,6 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
return ['title' => [['value' => $this->randomMachineName()]]] + parent::getNewEntityValues($langcode);
}
/**
* {@inheritdoc}
*/
protected function getFormSubmitAction(EntityInterface $entity, $langcode) {
if ($entity->getTranslation($langcode)->isPublished()) {
return t('Save and keep published') . $this->getFormSubmitSuffix($entity, $langcode);
}
else {
return t('Save and keep unpublished') . $this->getFormSubmitSuffix($entity, $langcode);
}
}
/**
* {@inheritdoc}
*/
@@ -158,18 +148,18 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
$entity = $storage->load($this->entityId);
$languages = $this->container->get('language_manager')->getLanguages();
$actions = [
t('Save and keep published'),
t('Save and unpublish'),
$statuses = [
TRUE,
FALSE,
];
foreach ($actions as $index => $action) {
foreach ($statuses as $index => $value) {
// (Un)publish the node translations and check that the translation
// statuses are (un)published accordingly.
foreach ($this->langcodes as $langcode) {
$options = ['language' => $languages[$langcode]];
$url = $entity->urlInfo('edit-form', $options);
$this->drupalPostForm($url, [], $action . $this->getFormSubmitSuffix($entity, $langcode), $options);
$this->drupalPostForm($url, ['status[value]' => $value], t('Save') . $this->getFormSubmitSuffix($entity, $langcode), $options);
}
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
@@ -0,0 +1,67 @@
<?php
namespace Drupal\Tests\node\Functional\Update;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
/**
* Tests that node settings are properly updated during database updates.
*
* @group node
*/
class NodeUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz',
];
}
/**
* Tests that the node entity type has a 'published' entity key.
*
* @see node_update_8301()
*/
public function testPublishedEntityKey() {
// Check that the 'published' entity key does not exist prior to the update.
$entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('node');
$this->assertFalse($entity_type->getKey('published'));
// Run updates.
$this->runUpdates();
// Check that the entity key exists and it has the correct value.
$entity_type = \Drupal::entityDefinitionUpdateManager()->getEntityType('node');
$this->assertEqual('status', $entity_type->getKey('published'));
}
/**
* Tests that the node entity form has the status checkbox.
*
* @see node_post_update_configure_status_field_widget()
*/
public function testStatusCheckbox() {
// Run updates.
$this->runUpdates();
$query = \Drupal::entityQuery('entity_form_display')
->condition('targetEntityType', 'node');
$ids = $query->execute();
$form_displays = EntityFormDisplay::loadMultiple($ids);
/**
* @var string $id
* @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display
*/
foreach ($form_displays as $id => $form_display) {
$component = $form_display->getComponent('status');
$this->assertEqual('boolean_checkbox', $component['type']);
$this->assertEqual(['display_label' => TRUE], $component['settings']);
}
}
}
@@ -67,9 +67,9 @@ class BulkFormAccessTest extends NodeTestBase {
// Create a private node (author may view, edit and delete, others may not).
$node = $this->drupalCreateNode([
'type' => 'article',
'private' => [[
'value' => TRUE,
]],
'private' => [
['value' => TRUE],
],
'uid' => $author->id(),
]);
// Create an account that may view the private node, but not edit it.
@@ -134,9 +134,9 @@ class BulkFormAccessTest extends NodeTestBase {
// Create a private node (author may view, edit and delete, others may not).
$private_node = $this->drupalCreateNode([
'type' => 'article',
'private' => [[
'value' => TRUE,
]],
'private' => [
['value' => TRUE],
],
'uid' => $author->id(),
]);
// Create an account that may view the private node, but not delete it.
@@ -146,9 +146,9 @@ class BulkFormAccessTest extends NodeTestBase {
// deleted by the author.
$own_node = $this->drupalCreateNode([
'type' => 'article',
'private' => [[
'value' => TRUE,
]],
'private' => [
['value' => TRUE],
],
'uid' => $account->id(),
]);
$this->drupalLogin($account);
@@ -170,19 +170,29 @@ class BulkFormTest extends NodeTestBase {
// operations are always applied to individual translations.
$edit = [
// Original and all translations.
'node_bulk_form[0]' => TRUE, // Node 1, English, original.
'node_bulk_form[1]' => TRUE, // Node 1, British English.
'node_bulk_form[2]' => TRUE, // Node 1, Italian.
// Node 1, English, original.
'node_bulk_form[0]' => TRUE,
// Node 1, British English.
'node_bulk_form[1]' => TRUE,
// Node 1, Italian.
'node_bulk_form[2]' => TRUE,
// Original and only one translation.
'node_bulk_form[3]' => TRUE, // Node 2, English.
'node_bulk_form[4]' => TRUE, // Node 2, British English, original.
'node_bulk_form[5]' => FALSE, // Node 2, Italian.
// Node 2, English.
'node_bulk_form[3]' => TRUE,
// Node 2, British English, original.
'node_bulk_form[4]' => TRUE,
// Node 2, Italian.
'node_bulk_form[5]' => FALSE,
// Only a single translation.
'node_bulk_form[6]' => TRUE, // Node 3, English.
'node_bulk_form[7]' => FALSE, // Node 3, Italian, original.
// Node 3, English.
'node_bulk_form[6]' => TRUE,
// Node 3, Italian, original.
'node_bulk_form[7]' => FALSE,
// Only a single untranslated node.
'node_bulk_form[8]' => TRUE, // Node 4, English, untranslated.
'node_bulk_form[9]' => FALSE, // Node 5, British English, untranslated.
// Node 4, English, untranslated.
'node_bulk_form[8]' => TRUE,
// Node 5, British English, untranslated.
'node_bulk_form[9]' => FALSE,
'action' => 'node_unpublish_action',
];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
@@ -211,19 +221,29 @@ class BulkFormTest extends NodeTestBase {
// nodes and individual translations are properly deleted.
$edit = [
// Original and all translations.
'node_bulk_form[0]' => TRUE, // Node 1, English, original.
'node_bulk_form[1]' => TRUE, // Node 1, British English.
'node_bulk_form[2]' => TRUE, // Node 1, Italian.
// Node 1, English, original.
'node_bulk_form[0]' => TRUE,
// Node 1, British English.
'node_bulk_form[1]' => TRUE,
// Node 1, Italian.
'node_bulk_form[2]' => TRUE,
// Original and only one translation.
'node_bulk_form[3]' => TRUE, // Node 2, English.
'node_bulk_form[4]' => TRUE, // Node 2, British English, original.
'node_bulk_form[5]' => FALSE, // Node 2, Italian.
// Node 2, English.
'node_bulk_form[3]' => TRUE,
// Node 2, British English, original.
'node_bulk_form[4]' => TRUE,
// Node 2, Italian.
'node_bulk_form[5]' => FALSE,
// Only a single translation.
'node_bulk_form[6]' => TRUE, // Node 3, English.
'node_bulk_form[7]' => FALSE, // Node 3, Italian, original.
// Node 3, English.
'node_bulk_form[6]' => TRUE,
// Node 3, Italian, original.
'node_bulk_form[7]' => FALSE,
// Only a single untranslated node.
'node_bulk_form[8]' => TRUE, // Node 4, English, untranslated.
'node_bulk_form[9]' => FALSE, // Node 5, British English, untranslated.
// Node 4, English, untranslated.
'node_bulk_form[8]' => TRUE,
// Node 5, British English, untranslated.
'node_bulk_form[9]' => FALSE,
'action' => 'node_delete_action',
];
$this->drupalPostForm(NULL, $edit, t('Apply to selected items'));
@@ -54,10 +54,12 @@ class FilterNodeAccessTest extends NodeTestBase {
$this->drupalLogin($web_user);
foreach ([0 => 'Public', 1 => 'Private'] as $is_private => $type) {
$settings = [
'body' => [[
'value' => $type . ' node',
'format' => filter_default_format(),
]],
'body' => [
[
'value' => $type . ' node',
'format' => filter_default_format(),
],
],
'title' => t('@private_public Article created by @user', ['@private_public' => $type, '@user' => $web_user->getUsername()]),
'type' => 'article',
'uid' => $web_user->id(),
@@ -0,0 +1,49 @@
<?php
namespace Drupal\Tests\node\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
/**
* Tests the JavaScript updating of summaries on content type form.
*
* @group node
*/
class TestSettingSummariesContentType extends JavascriptTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node'];
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$admin_user = $this->drupalCreateUser(['administer content types']);
$this->drupalLogin($admin_user);
$this->drupalCreateContentType(['type' => 'test']);
}
/**
* Test a vertical tab 'Workflow' summary.
*/
public function testWorkflowSummary() {
$this->drupalGet('admin/structure/types/manage/test');
$page = $this->getSession()->getPage();
$page->findField('options[status]')->uncheck();
$page->findField('options[sticky]')->check();
$page->findField('options[promote]')->check();
$page->findField('options[revision]')->check();
$locator = '[href="#edit-workflow"] .vertical-tabs__menu-item-summary';
$page->waitFor(10, function () use ($page, $locator) {
$summary = $page->find('css', $locator)->getText();
return strpos('Not published', $summary) !== FALSE;
});
$summary = $page->find('css', $locator)->getText();
$this->assertEquals('Not published, Promoted to front page, Sticky at top of lists, Create new revision', $summary);
}
}
@@ -0,0 +1,59 @@
<?php
namespace Drupal\Tests\node\Kernel\Migrate\d6;
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
use Symfony\Component\HttpFoundation\Request;
/**
* Tests node translation redirections.
*
* @group migrate_drupal
* @group node
*/
class NodeTranslationRedirectTest extends MigrateDrupal6TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'content_translation',
'language',
'menu_ui',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installConfig(['node']);
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['key_value']);
$this->migrateUsers(FALSE);
$this->migrateFields();
$this->executeMigrations([
'language',
'd6_language_types',
'd6_language_negotiation_settings',
'd6_node_settings',
'd6_node',
'd6_node_translation',
]);
}
/**
* Tests that not found node translations are redirected.
*/
public function testNodeTranslationRedirect() {
$kernel = $this->container->get('http_kernel');
$request = Request::create('/node/11');
$response = $kernel->handle($request);
$this->assertSame(301, $response->getStatusCode());
$this->assertSame('/node/10', $response->getTargetUrl());
}
}
@@ -18,22 +18,32 @@ class MigrateNodeDeriverTest extends MigrateDrupal7TestBase {
*/
protected $pluginManager;
/**
* The module handler service.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->pluginManager = $this->container->get('plugin.manager.migration');
$this->moduleHandler = $this->container->get('module_handler');
}
/**
* Test node translation migrations with translation disabled.
*/
public function testNoTranslations() {
// Enabling node module for this test.
$this->enableModules(['node']);
// Without content_translation, there should be no translation migrations.
$migrations = $this->pluginManager->createInstances('d7_node_translation');
$this->assertSame([], $migrations,
"No node translation migrations without content_translation");
$this->assertTrue($this->moduleHandler->moduleExists('node'));
$this->assertEmpty($migrations);
}
/**
@@ -2,6 +2,8 @@
namespace Drupal\Tests\node\Kernel\Migrate\d7;
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Tests\file\Kernel\Migrate\d7\FileMigrationSetupTrait;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
@@ -13,6 +15,8 @@ use Drupal\node\NodeInterface;
*/
class MigrateNodeTest extends MigrateDrupal7TestBase {
use FileMigrationSetupTrait;
/**
* {@inheritdoc}
*/
@@ -20,7 +24,9 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
'content_translation',
'comment',
'datetime',
'file',
'filter',
'forum',
'image',
'language',
'link',
@@ -37,11 +43,14 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
protected function setUp() {
parent::setUp();
$this->fileMigrationSetup();
$this->installEntitySchema('node');
$this->installEntitySchema('comment');
$this->installEntitySchema('taxonomy_term');
$this->installEntitySchema('file');
$this->installConfig(static::$modules);
$this->installSchema('comment', ['comment_entity_statistics']);
$this->installSchema('forum', ['forum', 'forum_index']);
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['sequences']);
@@ -52,6 +61,8 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
'd7_node_type',
'd7_language_content_settings',
'd7_comment_type',
'd7_comment_field',
'd7_comment_field_instance',
'd7_taxonomy_vocabulary',
'd7_field',
'd7_field_instance',
@@ -87,18 +98,18 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
protected function assertEntity($id, $type, $langcode, $title, $uid, $status, $created, $changed, $promoted, $sticky) {
/** @var \Drupal\node\NodeInterface $node */
$node = Node::load($id);
$this->assertTrue($node instanceof NodeInterface);
$this->assertIdentical($type, $node->getType());
$this->assertIdentical($langcode, $node->langcode->value);
$this->assertIdentical($title, $node->getTitle());
$this->assertIdentical($uid, $node->getOwnerId());
$this->assertIdentical($status, $node->isPublished());
$this->assertIdentical($created, $node->getCreatedTime());
$this->assertInstanceOf(NodeInterface::class, $node);
$this->assertEquals($type, $node->getType());
$this->assertEquals($langcode, $node->langcode->value);
$this->assertEquals($title, $node->getTitle());
$this->assertEquals($uid, $node->getOwnerId());
$this->assertEquals($status, $node->isPublished());
$this->assertEquals($created, $node->getCreatedTime());
if (isset($changed)) {
$this->assertIdentical($changed, $node->getChangedTime());
$this->assertEquals($changed, $node->getChangedTime());
}
$this->assertIdentical($promoted, $node->isPromoted());
$this->assertIdentical($sticky, $node->isSticky());
$this->assertEquals($promoted, $node->isPromoted());
$this->assertEquals($sticky, $node->isSticky());
}
/**
@@ -117,11 +128,11 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
*/
protected function assertRevision($id, $title, $uid, $log, $timestamp) {
$revision = \Drupal::entityManager()->getStorage('node')->loadRevision($id);
$this->assertTrue($revision instanceof NodeInterface);
$this->assertIdentical($title, $revision->getTitle());
$this->assertIdentical($uid, $revision->getRevisionUser()->id());
$this->assertIdentical($log, $revision->revision_log->value);
$this->assertIdentical($timestamp, $revision->getRevisionCreationTime());
$this->assertInstanceOf(NodeInterface::class, $revision);
$this->assertEquals($title, $revision->getTitle());
$this->assertEquals($uid, $revision->getRevisionUser()->id());
$this->assertEquals($log, $revision->revision_log->value);
$this->assertEquals($timestamp, $revision->getRevisionCreationTime());
}
/**
@@ -133,53 +144,64 @@ class MigrateNodeTest extends MigrateDrupal7TestBase {
$node = Node::load(1);
$this->assertTrue($node->field_boolean->value);
$this->assertIdentical('99-99-99-99', $node->field_phone->value);
// Use assertEqual() here instead, since SQLite interprets floats strictly.
$this->assertEqual('1', $node->field_float->value);
$this->assertIdentical('5', $node->field_integer->value);
$this->assertIdentical('Some more text', $node->field_text_list[0]->value);
$this->assertIdentical('7', $node->field_integer_list[0]->value);
$this->assertIdentical('qwerty', $node->field_text->value);
$this->assertIdentical('2', $node->field_file->target_id);
$this->assertIdentical('file desc', $node->field_file->description);
$this->assertEquals('99-99-99-99', $node->field_phone->value);
$this->assertEquals('1', $node->field_float->value);
$this->assertEquals('5', $node->field_integer->value);
$this->assertEquals('Some more text', $node->field_text_list[0]->value);
$this->assertEquals('7', $node->field_integer_list[0]->value);
$this->assertEquals('qwerty', $node->field_text->value);
$this->assertEquals('2', $node->field_file->target_id);
$this->assertEquals('file desc', $node->field_file->description);
$this->assertTrue($node->field_file->display);
$this->assertIdentical('1', $node->field_images->target_id);
$this->assertIdentical('alt text', $node->field_images->alt);
$this->assertIdentical('title text', $node->field_images->title);
$this->assertIdentical('93', $node->field_images->width);
$this->assertIdentical('93', $node->field_images->height);
$this->assertIdentical('http://google.com', $node->field_link->uri);
$this->assertIdentical('Click Here', $node->field_link->title);
$this->assertEquals('1', $node->field_images->target_id);
$this->assertEquals('alt text', $node->field_images->alt);
$this->assertEquals('title text', $node->field_images->title);
$this->assertEquals('93', $node->field_images->width);
$this->assertEquals('93', $node->field_images->height);
$this->assertEquals('http://google.com', $node->field_link->uri);
$this->assertEquals('Click Here', $node->field_link->title);
// Test that an email field is migrated.
$this->assertSame('default@example.com', $node->field_email->value);
$this->assertSame('another@example.com', $node->field_email[1]->value);
$this->assertEquals('default@example.com', $node->field_email->value);
$this->assertEquals('another@example.com', $node->field_email[1]->value);
$this->assertEquals(CommentItemInterface::OPEN, $node->comment_node_test_content_type->status);
$node = Node::load(2);
$this->assertSame('en', $node->langcode->value);
$this->assertIdentical("...is that it's the absolute best show ever. Trust me, I would know.", $node->body->value);
$this->assertSame('The thing about Deep Space 9', $node->label());
$this->assertIdentical('internal:/', $node->field_link->uri);
$this->assertIdentical('Home', $node->field_link->title);
$this->assertEquals('en', $node->langcode->value);
$this->assertEquals("...is that it's the absolute best show ever. Trust me, I would know.", $node->body->value);
$this->assertEquals('The thing about Deep Space 9', $node->label());
$this->assertEquals('internal:/', $node->field_link->uri);
$this->assertEquals('Home', $node->field_link->title);
$this->assertEquals(CommentItemInterface::OPEN, $node->comment_node_article->status);
$this->assertTrue($node->hasTranslation('is'), "Node 2 has an Icelandic translation");
$translation = $node->getTranslation('is');
$this->assertSame('is', $translation->langcode->value);
$this->assertSame("is - ...is that it's the absolute best show ever. Trust me, I would know.", $translation->body->value);
$this->assertSame('is - The thing about Deep Space 9', $translation->label());
$this->assertSame('internal:/', $translation->field_link->uri);
$this->assertSame('Home', $translation->field_link->title);
$this->assertEquals('is', $translation->langcode->value);
$this->assertEquals("is - ...is that it's the absolute best show ever. Trust me, I would know.", $translation->body->value);
$this->assertEquals('is - The thing about Deep Space 9', $translation->label());
$this->assertEquals('internal:/', $translation->field_link->uri);
$this->assertEquals(CommentItemInterface::OPEN, $translation->comment_node_article->status);
$this->assertEquals('Home', $translation->field_link->title);
// Test that content_translation_source is set.
$manager = $this->container->get('content_translation.manager');
$this->assertSame('en', $manager->getTranslationMetadata($node->getTranslation('is'))->getSource());
$this->assertEquals('en', $manager->getTranslationMetadata($node->getTranslation('is'))->getSource());
// Node 3 is a translation of node 2, and should not be imported separately.
$this->assertNull(Node::load(3), "Node 3 doesn't exist in D8, it was a translation");
// Test that content_translation_source for a source other than English.
$node = Node::load(4);
$this->assertSame('is', $manager->getTranslationMetadata($node->getTranslation('en'))->getSource());
$this->assertEquals('is', $manager->getTranslationMetadata($node->getTranslation('en'))->getSource());
$this->assertEquals(CommentItemInterface::CLOSED, $node->comment_node_article->status);
$translation = $node->getTranslation('en');
$this->assertEquals(CommentItemInterface::CLOSED, $translation->comment_node_article->status);
$node = Node::load(6);
$this->assertEquals(CommentItemInterface::CLOSED, $node->comment_forum->status);
$node = Node::load(7);
$this->assertEquals(CommentItemInterface::OPEN, $node->comment_forum->status);
}
}
@@ -0,0 +1,61 @@
<?php
namespace Drupal\Tests\node\Kernel\Migrate\d7;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
use Symfony\Component\HttpFoundation\Request;
/**
* Tests node translation redirections.
*
* @group migrate_drupal
* @group node
*/
class NodeTranslationRedirectTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'content_translation',
'language',
'menu_ui',
'node',
'text',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('node');
$this->installConfig('node');
$this->installSchema('node', ['node_access']);
$this->installSchema('system', ['key_value']);
$this->executeMigrations([
'language',
'd7_language_types',
'd7_language_negotiation_settings',
'd7_user_role',
'd7_user',
'd7_node_type',
'd7_node',
'd7_node_translation',
]);
}
/**
* Tests that not found node translations are redirected.
*/
public function testNodeTranslationRedirect() {
$kernel = $this->container->get('http_kernel');
$request = Request::create('/node/3');
$response = $kernel->handle($request);
$this->assertSame(301, $response->getStatusCode());
$this->assertSame('/node/2', $response->getTargetUrl());
}
}
@@ -57,9 +57,139 @@ class NodeTypeTest extends MigrateSqlSourceTestBase {
'orig_type' => 'story',
],
];
$tests[0]['source_data']['variable'] = [
[
'name' => 'comment_anonymous_page',
'value' => 'i:0;',
],
[
'name' => 'comment_anonymous_story',
'value' => 'i:1;',
],
[
'name' => 'comment_default_mode_page',
'value' => 'i:0;',
],
[
'name' => 'comment_default_mode_story',
'value' => 'i:1;',
],
[
'name' => 'comment_default_per_page_page',
'value' => 's:2:"10";',
],
[
'name' => 'comment_default_per_page_story',
'value' => 's:2:"20";',
],
[
'name' => 'comment_form_location_page',
'value' => 'i:0;',
],
[
'name' => 'comment_form_location_story',
'value' => 'i:1;',
],
[
'name' => 'comment_page',
'value' => 's:1:"0";',
],
[
'name' => 'comment_preview_page',
'value' => 's:1:"0";',
],
[
'name' => 'comment_preview_story',
'value' => 's:1:"1";',
],
[
'name' => 'comment_story',
'value' => 's:1:"1";',
],
[
'name' => 'comment_subject_field_page',
'value' => 'i:0;',
],
[
'name' => 'comment_subject_field_story',
'value' => 'i:1;',
],
[
'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']['system'] = [
[
'type' => 'module',
'name' => 'comment',
'status' => '1',
],
];
// The expected results.
$tests[0]['expected_data'] = $tests[0]['source_data']['node_type'];
$tests[0]['expected_data'] = [
[
'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',
'options' => [
'promote' => FALSE,
'sticky' => FALSE,
'status' => TRUE,
'revision' => FALSE,
],
'comment' => 0,
'comment_default_mode' => 0,
'comment_default_per_page' => '10',
'comment_anonymous' => 0,
'comment_subject_field' => 0,
'comment_preview' => 0,
'comment_form_location' => 0,
],
[
'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',
'options' => [
'promote' => FALSE,
'sticky' => FALSE,
'status' => TRUE,
'revision' => FALSE,
],
'comment' => 1,
'comment_default_mode' => 1,
'comment_default_per_page' => '20',
'comment_anonymous' => 1,
'comment_subject_field' => 1,
'comment_preview' => 1,
'comment_form_location' => 1,
],
];
return $tests;
}
@@ -54,6 +54,62 @@ class NodeTypeTest extends MigrateSqlSourceTestBase {
],
];
$tests[0]['source_data']['variable'] = [
[
'name' => 'comment_anonymous_page',
'value' => 'i:0;',
],
[
'name' => 'comment_anonymous_story',
'value' => 'i:1;',
],
[
'name' => 'comment_default_mode_page',
'value' => 'i:0;',
],
[
'name' => 'comment_default_mode_story',
'value' => 'i:1;',
],
[
'name' => 'comment_default_per_page_page',
'value' => 's:2:"10";',
],
[
'name' => 'comment_default_per_page_story',
'value' => 's:2:"20";',
],
[
'name' => 'comment_form_location_page',
'value' => 'i:0;',
],
[
'name' => 'comment_form_location_story',
'value' => 'i:1;',
],
[
'name' => 'comment_page',
'value' => 's:1:"0";',
],
[
'name' => 'comment_preview_page',
'value' => 's:1:"0";',
],
[
'name' => 'comment_preview_story',
'value' => 's:1:"1";',
],
[
'name' => 'comment_story',
'value' => 's:1:"1";',
],
[
'name' => 'comment_subject_field_page',
'value' => 'i:0;',
],
[
'name' => 'comment_subject_field_story',
'value' => 'i:1;',
],
[
'name' => 'node_options_page',
'value' => 'a:1:{i:0;s:6:"status";}',
@@ -77,9 +133,78 @@ class NodeTypeTest extends MigrateSqlSourceTestBase {
'data' => 'a:1:{s:5:"label";s:4:"Body";}',
],
];
$tests[0]['source_data']['system'] = [
[
'type' => 'module',
'name' => 'comment',
'status' => '1',
],
[
'type' => 'module',
'name' => 'field',
'status' => '1',
],
];
// The expected results.
$tests[0]['expected_data'] = $tests[0]['source_data']['node_type'];
$tests[0]['expected_data'] = [
[
'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',
'options' => [
'promote' => FALSE,
'sticky' => FALSE,
'status' => TRUE,
'revision' => FALSE,
],
'create_body' => TRUE,
'body_label' => 'Body',
'comment' => 0,
'comment_default_mode' => 0,
'comment_default_per_page' => '10',
'comment_anonymous' => 0,
'comment_subject_field' => 0,
'comment_preview' => 0,
'comment_form_location' => 0,
],
[
'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',
'options' => [
'promote' => FALSE,
'sticky' => FALSE,
'status' => TRUE,
'revision' => FALSE,
],
'create_body' => TRUE,
'body_label' => 'Body',
'comment' => 1,
'comment_default_mode' => 1,
'comment_default_per_page' => '20',
'comment_anonymous' => 1,
'comment_subject_field' => 1,
'comment_preview' => 1,
'comment_form_location' => 1,
],
];
return $tests;
}
@@ -0,0 +1,54 @@
<?php
namespace Drupal\Tests\node\Traits;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\node\Entity\NodeType;
use PHPUnit\Framework\TestCase;
/**
* Provides methods to create content type from given values.
*
* This trait is meant to be used only by test classes.
*/
trait ContentTypeCreationTrait {
/**
* Creates a custom content type based on default settings.
*
* @param array $values
* An array of settings to change from the defaults.
* Example: 'type' => 'foo'.
*
* @return \Drupal\node\Entity\NodeType
* Created content type.
*/
protected function createContentType(array $values = []) {
// Find a non-existent random type name.
if (!isset($values['type'])) {
do {
$id = strtolower($this->randomMachineName(8));
} while (NodeType::load($id));
}
else {
$id = $values['type'];
}
$values += [
'type' => $id,
'name' => $id,
];
$type = NodeType::create($values);
$status = $type->save();
node_add_body_field($type);
if ($this instanceof TestCase) {
$this->assertSame($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', ['%type' => $type->id()]))->__toString());
}
else {
$this->assertEqual($status, SAVED_NEW, (new FormattableMarkup('Created content type %type.', ['%type' => $type->id()]))->__toString());
}
return $type;
}
}
@@ -0,0 +1,86 @@
<?php
namespace Drupal\Tests\node\Traits;
use Drupal\node\Entity\Node;
/**
* Provides methods to create node based on default settings.
*
* This trait is meant to be used only by test classes.
*/
trait NodeCreationTrait {
/**
* Get a node from the database based on its title.
*
* @param string|\Drupal\Component\Render\MarkupInterface $title
* A node title, usually generated by $this->randomMachineName().
* @param $reset
* (optional) Whether to reset the entity cache.
*
* @return \Drupal\node\NodeInterface
* A node entity matching $title.
*/
public function getNodeByTitle($title, $reset = FALSE) {
if ($reset) {
\Drupal::entityTypeManager()->getStorage('node')->resetCache();
}
// Cast MarkupInterface objects to string.
$title = (string) $title;
$nodes = \Drupal::entityTypeManager()
->getStorage('node')
->loadByProperties(['title' => $title]);
// Load the first node returned from the database.
$returned_node = reset($nodes);
return $returned_node;
}
/**
* Creates a node based on default settings.
*
* @param array $settings
* (optional) An associative array of settings for the node, as used in
* entity_create(). Override the defaults by specifying the key and value
* in the array, for example:
* @code
* $this->drupalCreateNode(array(
* 'title' => t('Hello, world!'),
* 'type' => 'article',
* ));
* @endcode
* The following defaults are provided:
* - body: Random string using the default filter format:
* @code
* $settings['body'][0] = array(
* 'value' => $this->randomMachineName(32),
* 'format' => filter_default_format(),
* );
* @endcode
* - title: Random string.
* - type: 'page'.
* - uid: The currently logged in user, or anonymous.
*
* @return \Drupal\node\NodeInterface
* The created node entity.
*/
protected function createNode(array $settings = []) {
// Populate defaults array.
$settings += [
'body' => [
[
'value' => $this->randomMachineName(32),
'format' => filter_default_format(),
],
],
'title' => $this->randomMachineName(8),
'type' => 'page',
'uid' => \Drupal::currentUser()->id(),
];
$node = Node::create($settings);
$node->save();
return $node;
}
}