updated core from 8.4 to 8.5 : bug with login_destination

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-13 14:01:21 +01:00
parent 0d78da249b
commit e668535a4e
3486 changed files with 89604 additions and 33283 deletions
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- options
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -5,8 +5,8 @@ description: 'Support module for node configuration tests.'
package: Testing
# version: VERSION
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -9,8 +9,8 @@ dependencies:
- views
- language
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -0,0 +1,131 @@
<?php
namespace Drupal\Tests\node\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
/**
* Tests that the node_access system stores the proper fallback marker.
*
* @group node
*/
class NodeAccessLanguageFallbackTest extends NodeTestBase {
/**
* Enable language and a non-language-aware node access module.
*
* @var array
*/
public static $modules = ['language', 'node_access_test', 'content_translation'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// After enabling a node access module, the {node_access} table has to be
// rebuilt.
node_access_rebuild();
// Add Hungarian, Catalan, and Afrikaans.
ConfigurableLanguage::createFromLangcode('hu')->save();
ConfigurableLanguage::createFromLangcode('ca')->save();
ConfigurableLanguage::createFromLangcode('af')->save();
// Enable content translation for the current entity type.
\Drupal::service('content_translation.manager')->setEnabled('node', 'page', TRUE);
}
/**
* Tests node access fallback handling with multiple node languages.
*/
public function testNodeAccessLanguageFallback() {
// The node_access_test module allows nodes to be marked private. We need to
// ensure that system honors the fallback system of node access properly.
// Note that node_access_test_language is language-sensitive and does not
// apply to the fallback test.
// Create one node in Hungarian and marked as private.
$node = $this->drupalCreateNode([
'body' => [[]],
'langcode' => 'hu',
'private' => [['value' => 1]],
'status' => 1,
]);
// There should be one entry in node_access, with fallback set to hu.
$this->checkRecords(1, 'hu');
// Create a translation user.
$admin = $this->drupalCreateUser([
'bypass node access',
'administer nodes',
'translate any entity',
'administer content translation',
]);
$this->drupalLogin($admin);
$this->drupalGet('node/' . $node->id() . '/translations');
$this->assertSession()->statusCodeEquals(200);
// Create a Catalan translation through the UI.
$url_options = ['language' => \Drupal::languageManager()->getLanguage('ca')];
$this->drupalGet('node/' . $node->id() . '/translations/add/hu/ca', $url_options);
$this->assertSession()->statusCodeEquals(200);
// Save the form.
$this->getSession()->getPage()->pressButton('Save (this translation)');
$this->assertSession()->statusCodeEquals(200);
// Check the node access table.
$this->checkRecords(2, 'hu');
// Programmatically create a translation. This process lets us check that
// both forms and code behave in the same way.
$storage = \Drupal::entityTypeManager()->getStorage('node');
// Reload the node.
$node = $storage->load(1);
// Create an Afrikaans translation.
$translation = $node->addTranslation('af');
$translation->title->value = $this->randomString();
$translation->status = 1;
$node->save();
// Check the node access table.
$this->checkRecords(3, 'hu');
// For completeness, edit the Catalan version again.
$this->drupalGet('node/' . $node->id() . '/edit', $url_options);
$this->assertSession()->statusCodeEquals(200);
// Save the form.
$this->getSession()->getPage()->pressButton('Save (this translation)');
$this->assertSession()->statusCodeEquals(200);
// Check the node access table.
$this->checkRecords(3, 'hu');
}
/**
* Queries the node_access table and checks for proper storage.
*
* @param int $count
* The number of rows expected by the query (equal to the translation
* count).
* @param $langcode
* The expected language code set as the fallback property.
*/
public function checkRecords($count, $langcode = 'hu') {
$select = \Drupal::database()
->select('node_access', 'na')
->fields('na', ['nid', 'fallback', 'langcode', 'grant_view'])
->condition('na.realm', 'node_access_test', '=')
->condition('na.gid', 8888, '=');
$records = $select->execute()->fetchAll();
// Check that the expected record count is returned.
$this->assertEquals(count($records), $count);
// The fallback value is 'hu' and should be set to 1. For other languages,
// it should be set to 0. Casting to boolean lets us run that comparison.
foreach ($records as $record) {
$this->assertEquals((bool) $record->fallback, $record->langcode === $langcode);
}
}
}
@@ -2,7 +2,6 @@
namespace Drupal\Tests\node\Functional;
use Drupal\Component\Utility\Crypt;
use Drupal\Tests\BrowserTestBase;
use Drupal\system\Entity\Action;
@@ -30,7 +29,7 @@ class NodeActionsConfigurationTest extends BrowserTestBase {
// Make a POST request to admin/config/system/actions.
$edit = [];
$edit['action'] = Crypt::hashBase64('node_assign_owner_action');
$edit['action'] = 'node_assign_owner_action';
$this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
$this->assertResponse(200);
@@ -40,17 +39,17 @@ class NodeActionsConfigurationTest extends BrowserTestBase {
$edit['label'] = $action_label;
$edit['id'] = strtolower($action_label);
$edit['owner_uid'] = $user->id();
$this->drupalPostForm('admin/config/system/actions/add/' . Crypt::hashBase64('node_assign_owner_action'), $edit, t('Save'));
$this->drupalPostForm('admin/config/system/actions/add/node_assign_owner_action', $edit, t('Save'));
$this->assertResponse(200);
$action_id = $edit['id'];
// Make sure that the new action was saved properly.
$this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully saved.');
$this->assertText($action_label, 'The label of the node_assign_owner_action action appears on the actions administration page after saving.');
// Make another POST request to the action edit page.
$this->clickLink(t('Configure'));
preg_match('|admin/config/system/actions/configure/(.+)|', $this->getUrl(), $matches);
$aid = $matches[1];
$edit = [];
$new_action_label = $this->randomMachineName();
$edit['label'] = $new_action_label;
@@ -68,7 +67,7 @@ class NodeActionsConfigurationTest extends BrowserTestBase {
$this->clickLink(t('Delete'));
$this->assertResponse(200);
$edit = [];
$this->drupalPostForm("admin/config/system/actions/configure/$aid/delete", $edit, t('Delete'));
$this->drupalPostForm(NULL, $edit, t('Delete'));
$this->assertResponse(200);
// Make sure that the action was actually deleted.
@@ -77,7 +76,7 @@ class NodeActionsConfigurationTest extends BrowserTestBase {
$this->assertResponse(200);
$this->assertNoText($new_action_label, 'The label for the node_assign_owner_action action does not appear on the actions administration page after deleting.');
$action = Action::load($aid);
$action = Action::load($action_id);
$this->assertFalse($action, 'The node_assign_owner_action action is not available after being deleted.');
}
@@ -0,0 +1,42 @@
<?php
namespace Drupal\Tests\node\Functional;
use Drupal\node\Entity\Node;
/**
* Tests views contextual links on nodes.
*
* @group node
*/
class NodeContextualLinksTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'contextual',
];
/**
* Tests contextual links.
*/
public function testNodeContextualLinks() {
// Create a node item.
$node = Node::create([
'type' => 'article',
'title' => 'Unnamed',
]);
$node->save();
$user = $this->drupalCreateUser([
'administer nodes',
'access contextual links',
]);
$this->drupalLogin($user);
$this->drupalGet('node/' . $node->id());
$this->assertSession()->elementAttributeContains('css', 'div[data-contextual-id]', 'data-contextual-id', 'node:node=' . $node->id() . ':');
}
}
@@ -160,10 +160,17 @@ class NodeRevisionsUiTest extends NodeTestBase {
$this->drupalGet('node/' . $node_id . '/revisions');
// Verify that the latest affected revision having been a default revision
// is displayed as the current one.
$this->assertNoLinkByHref('/node/' . $node_id . '/revisions/1/revert');
$elements = $this->xpath('//tr[contains(@class, "revision-current")]/td/a[1]');
// The site may be installed in a subdirectory, so check if the URL is
// contained in the retrieved one.
$this->assertContains('/node/1', current($elements)->getAttribute('href'));
// Verify that the default revision can be an older revision than the latest
// one.
// Assert that the revisions with translations changes are shown: 1 and 4.
$this->assertLinkByHref('/node/' . $node_id . '/revisions/1/revert');
// Assert that the revisions with translations changes are shown.
$this->assertLinkByHref('/node/' . $node_id . '/revisions/4/revert');
// Assert that the revisions without translations changes are filtered out:
@@ -21,13 +21,15 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
*/
protected $defaultCacheContexts = [
'languages:language_interface',
'session',
'theme',
'route',
'timezone',
'url.path.parent',
'url.query_args:_wrapper_format',
'user'
'user.roles',
// These two cache contexts are added by BigPipe.
'cookies:big_pipe_nojs',
'session.exists',
];
/**
@@ -45,16 +45,19 @@ class NodeRevisionWizardTest extends WizardTestBase {
$view['show[wizard_key]'] = 'node_revision';
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
$view_storage_controller = \Drupal::entityManager()->getStorage('view');
/** @var \Drupal\views\Entity\View $view */
$view = $view_storage_controller->load($view['id']);
$view = Views::getView($view['id']);
$view->initHandlers();
$this->assertEqual($view->get('base_table'), 'node_field_revision');
$this->assertEqual($view->getBaseTables(), ['node_field_revision' => TRUE, '#global' => TRUE]);
$executable = Views::executableFactory()->get($view);
$this->executeView($executable);
// Check for the default filters.
$this->assertEqual($view->filter['status']->table, 'node_field_revision');
$this->assertEqual($view->filter['status']->field, 'status');
$this->assertTrue($view->filter['status']->value);
$this->assertIdenticalResultset($executable, [['vid' => 1], ['vid' => 3], ['vid' => 2], ['vid' => 4]],
$this->executeView($view);
$this->assertIdenticalResultset($view, [['vid' => 1], ['vid' => 3], ['vid' => 2], ['vid' => 4]],
['vid' => 'vid']);
}
@@ -58,12 +58,18 @@ class PathPluginTest extends NodeTestBase {
}
/**
* Tests the node path plugin.
* Tests the node path plugin functionality when converted to entity link.
*/
public function testPathPlugin() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = $this->container->get('renderer');
$view = Views::getView('test_node_path_plugin');
// The configured deprecated node path plugin should be converted to the
// entity link plugin.
$field = $view->getHandler('page_1', 'field', 'path');
$this->assertEqual('entity_link', $field['plugin_id']);
$view->initDisplay();
$view->setDisplay('page_1');
$view->initStyle();
@@ -42,9 +42,7 @@ class MigrateNodeDeriverTest extends MigrateDrupal6TestBase {
// With content_translation, there should be translation migrations for
// each content type.
$this->enableModules(['language', 'content_translation']);
$migrations = $this->pluginManager->createInstances('d6_node_translation');
$this->assertArrayHasKey('d6_node_translation:story', $migrations,
"Node translation migrations exist after content_translation installed");
$this->assertTrue($this->container->get('plugin.manager.migration')->hasDefinition('d6_node_translation:story'), "Node translation migrations exist after content_translation installed");
}
}
@@ -11,38 +11,17 @@ use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
*/
class MigrateNodeDeriverTest extends MigrateDrupal7TestBase {
/**
* The migration plugin manager.
*
* @var \Drupal\migrate\Plugin\MigrationPluginManagerInterface
*/
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');
}
public static $modules = ['node'];
/**
* 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->assertTrue($this->moduleHandler->moduleExists('node'));
$migrations = $this->container->get('plugin.manager.migration')->createInstances('d7_node_translation');
$this->assertEmpty($migrations);
}
@@ -52,10 +31,8 @@ class MigrateNodeDeriverTest extends MigrateDrupal7TestBase {
public function testTranslations() {
// With content_translation, there should be translation migrations for
// each content type.
$this->enableModules(['language', 'content_translation', 'node', 'filter']);
$migrations = $this->pluginManager->createInstances('d7_node_translation');
$this->assertArrayHasKey('d7_node_translation:article', $migrations,
"Node translation migrations exist after content_translation installed");
$this->enableModules(['language', 'content_translation', 'filter']);
$this->assertTrue($this->container->get('plugin.manager.migration')->hasDefinition('d7_node_translation:article'), "Node translation migrations exist after content_translation installed");
}
}
@@ -0,0 +1,101 @@
<?php
namespace Drupal\Tests\node\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\user\Entity\User;
/**
* Tests the node view builder.
*
* @group node
*
* @coversDefaultClass \Drupal\node\NodeViewBuilder
*/
class NodeViewBuilderTest extends EntityKernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['node'];
/**
* The node storage.
*
* @var \Drupal\node\NodeStorageInterface
*/
protected $storage;
/**
* The node view builder.
*
* @var \Drupal\Core\Entity\EntityViewBuilderInterface
*/
protected $viewBuilder;
/**
* The renderer.
*
* @var \Drupal\Core\Render\RendererInterface
*/
protected $renderer;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->storage = $this->entityManager->getStorage('node');
$this->viewBuilder = $this->entityManager->getViewBuilder('node');
$this->renderer = $this->container->get('renderer');
$type = NodeType::create([
'type' => 'article',
'name' => 'Article',
]);
$type->save();
$this->installSchema('node', 'node_access');
$this->installConfig(['system', 'node']);
}
/**
* Tests that node links are displayed correctly in pending revisions.
*
* @covers ::buildComponents
* @covers ::renderLinks
* @covers ::buildLinks
*/
public function testPendingRevisionLinks() {
$account = User::create([
'name' => $this->randomString(),
]);
$account->save();
$title = $this->randomMachineName();
$node = Node::create([
'type' => 'article',
'title' => $title,
'uid' => $account->id(),
]);
$node->save();
/** @var \Drupal\node\NodeInterface $pending_revision */
$pending_revision = $this->storage->createRevision($node, FALSE);
$draft_title = $title . ' draft';
$pending_revision->setTitle($draft_title);
$pending_revision->save();
$build = $this->viewBuilder->view($node, 'teaser');
$output = (string) $this->renderer->renderPlain($build);
$this->assertContains("title=\"$title\"", $output);
$build = $this->viewBuilder->view($pending_revision, 'teaser');
$output = (string) $this->renderer->renderPlain($build);
$this->assertContains("title=\"$draft_title\"", $output);
}
}