Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713

This commit is contained in:
Pantheon Automation 2016-05-04 14:35:41 -07:00 committed by Greg Anderson
parent c0a0d5a94c
commit 9eae24d844
669 changed files with 3873 additions and 1553 deletions

View file

@ -208,15 +208,15 @@ function hook_node_access_records(\Drupal\node\NodeInterface $node) {
*
* A module may deny all access to a node by setting $grants to an empty array.
*
* The preferred use of this hook is in a module that bridges multiple node
* access modules with a configurable behavior, as shown in the example with the
* 'is_preview' field.
*
* @param array $grants
* The $grants array returned by hook_node_access_records().
* @param \Drupal\node\NodeInterface $node
* The node for which the grants were acquired.
*
* The preferred use of this hook is in a module that bridges multiple node
* access modules with a configurable behavior, as shown in the example with the
* 'is_preview' field.
*
* @see hook_node_access_records()
* @see hook_node_grants()
* @see hook_node_grants_alter()

View file

@ -742,7 +742,7 @@ function node_get_recent($number = 10) {
// If the user is able to view their own unpublished nodes, allow them
// to see these in addition to published nodes. Check that they actually
// have some unpublished nodes to view before adding the condition.
$access_query = \Drupal::entityQuery('node')
$access_query = \Drupal::entityQuery('node')
->condition('uid', $account->id())
->condition('status', NODE_NOT_PUBLISHED);
if ($account->hasPermission('view own unpublished content') && ($own_unpublished = $access_query->execute())) {
@ -1172,7 +1172,7 @@ function node_access_rebuild($batch_mode = FALSE) {
// user does not have access. And unless the current user has the bypass
// node access permission, no nodes are accessible since the grants have
// just been deleted.
$entity_query->accessCheck(false);
$entity_query->accessCheck(FALSE);
$nids = $entity_query->execute();
foreach ($nids as $nid) {
$node_storage->resetCache(array($nid));
@ -1227,7 +1227,7 @@ function _node_access_rebuild_batch_operation(&$context) {
// user does not have access. And unless the current user has the bypass
// node access permission, no nodes are accessible since the grants have
// just been deleted.
->accessCheck(false)
->accessCheck(FALSE)
->range(0, $limit)
->execute();
$node_storage->resetCache($nids);

View file

@ -17,7 +17,7 @@ function node_views_query_substitutions(ViewExecutable $view) {
return array(
'***ADMINISTER_NODES***' => intval($account->hasPermission('administer nodes')),
'***VIEW_OWN_UNPUBLISHED_NODES***' => intval($account->hasPermission('view own unpublished content')),
'***BYPASS_NODE_ACCESS***' => intval($account->hasPermission('bypass node access')),
'***BYPASS_NODE_ACCESS***' => intval($account->hasPermission('bypass node access')),
);
}

View file

@ -168,7 +168,7 @@ class NodeController extends ControllerBase implements ContainerInjectionInterfa
$header = array($this->t('Revision'), $this->t('Operations'));
$revert_permission = (($account->hasPermission("revert $type revisions") || $account->hasPermission('revert all revisions') || $account->hasPermission('administer nodes')) && $node->access('update'));
$delete_permission = (($account->hasPermission("delete $type revisions") || $account->hasPermission('delete all revisions') || $account->hasPermission('administer nodes')) && $node->access('delete'));
$delete_permission = (($account->hasPermission("delete $type revisions") || $account->hasPermission('delete all revisions') || $account->hasPermission('administer nodes')) && $node->access('delete'));
$rows = array();

View file

@ -147,7 +147,7 @@ class NodeViewBuilder extends EntityViewBuilder {
parent::alterBuild($build, $entity, $display, $view_mode);
if ($entity->id()) {
$build['#contextual_links']['node'] = array(
'route_parameters' =>array('node' => $entity->id()),
'route_parameters' => array('node' => $entity->id()),
'metadata' => array('changed' => $entity->getChangedTime()),
);
}

View file

@ -117,7 +117,7 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
$exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', 0, 1, array(':name' => $form_state->getValue('owner_uid')))->fetchField();
$exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users_field_data} WHERE uid = :uid AND default_langcode = 1', 0, 1, array(':uid' => $form_state->getValue('owner_uid')))->fetchField();
if (!$exists) {
$form_state->setErrorByName('owner_uid', t('Enter a valid username.'));
}

View file

@ -525,7 +525,7 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
$used_advanced = !empty($parameters[self::ADVANCED_FORM]);
if ($used_advanced) {
$f = isset($parameters['f']) ? (array) $parameters['f'] : array();
$defaults = $this->parseAdvancedDefaults($f, $keys);
$defaults = $this->parseAdvancedDefaults($f, $keys);
}
else {
$defaults = array('keys' => $keys);

View file

@ -0,0 +1,84 @@
<?php
namespace Drupal\node\Tests;
use Drupal\Component\Utility\Crypt;
use Drupal\simpletest\WebTestBase;
use Drupal\system\Entity\Action;
/**
* Tests configuration of actions provided by the Node module.
*
* @group node
*/
class NodeActionsConfigurationTest extends WebTestBase {
/**
* Modules to install.
*
* @var array
*/
public static $modules = ['action', 'node'];
/**
* Tests configuration of the node_assign_owner_action action.
*/
public function testAssignOwnerNodeActionConfiguration() {
// Create a user with permission to view the actions administration pages.
$user = $this->drupalCreateUser(['administer actions']);
$this->drupalLogin($user);
// Make a POST request to admin/config/system/actions.
$edit = [];
$edit['action'] = Crypt::hashBase64('node_assign_owner_action');
$this->drupalPostForm('admin/config/system/actions', $edit, t('Create'));
$this->assertResponse(200);
// Make a POST request to the individual action configuration page.
$edit = [];
$action_label = $this->randomMachineName();
$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->assertResponse(200);
// 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;
$edit['owner_uid'] = $user->id();
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertResponse(200);
// Make sure that the action updated properly.
$this->assertText(t('The action has been successfully saved.'), 'The node_assign_owner_action action has been successfully updated.');
$this->assertNoText($action_label, 'The old label for the node_assign_owner_action action does not appear on the actions administration page after updating.');
$this->assertText($new_action_label, 'The new label for the node_assign_owner_action action appears on the actions administration page after updating.');
// Make sure that deletions work properly.
$this->drupalGet('admin/config/system/actions');
$this->clickLink(t('Delete'));
$this->assertResponse(200);
$edit = [];
$this->drupalPostForm("admin/config/system/actions/configure/$aid/delete", $edit, t('Delete'));
$this->assertResponse(200);
// Make sure that the action was actually deleted.
$this->assertRaw(t('The action %action has been deleted.', ['%action' => $new_action_label]), 'The delete confirmation message appears after deleting the node_assign_owner_action action.');
$this->drupalGet('admin/config/system/actions');
$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);
$this->assertFalse($action, 'The node_assign_owner_action action is not available after being deleted.');
}
}

View file

@ -123,7 +123,7 @@ class NodeBlockFunctionalTest extends NodeTestBase {
'region' => 'sidebar_first',
'visibility[node_type][bundles][article]' => 'article',
];
$theme = \Drupal::service('theme_handler')->getDefault();
$theme = \Drupal::service('theme_handler')->getDefault();
$this->drupalPostForm("admin/structure/block/add/system_powered_by_block/$theme", $edit, t('Save block'));
$block = Block::load($edit['id']);

View file

@ -91,7 +91,7 @@ class NodeEditFormTest extends NodeTestBase {
$this->assertText($edit[$title_key], 'Title displayed.');
$this->assertText($edit[$body_key], 'Body displayed.');
// Login as a second administrator user.
// Log in as a second administrator user.
$second_web_user = $this->drupalCreateUser(array('administer nodes', 'edit any page content'));
$this->drupalLogin($second_web_user);
// Edit the same node, creating a new revision.

View file

@ -39,7 +39,7 @@ class NodeFormButtonsTest extends NodeTestBase {
*/
function testNodeFormButtons() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
// Login as administrative user.
// Log in as administrative user.
$this->drupalLogin($this->adminUser);
// Verify the buttons on a node add form.
@ -91,7 +91,7 @@ class NodeFormButtonsTest extends NodeTestBase {
$node_2 = $node_storage->load(2);
$this->assertTrue($node_2->isPublished(), 'Node is published');
// Login as an administrator and unpublish the node that just
// Log in as an administrator and unpublish the node that just
// was created by the normal user.
$this->drupalLogout();
$this->drupalLogin($this->adminUser);
@ -100,7 +100,7 @@ class NodeFormButtonsTest extends NodeTestBase {
$node_2 = $node_storage->load(2);
$this->assertFalse($node_2->isPublished(), 'Node is unpublished');
// Login again as the normal user, save the node and verify
// Log in again as the normal user, save the node and verify
// it's still unpublished.
$this->drupalLogout();
$this->drupalLogin($this->webUser);

View file

@ -74,7 +74,7 @@ class NodeRevisionsAllTest extends NodeTestBase {
// Get last node for simple checks.
$node = $nodes[3];
// Create and login user.
// Create and log in user.
$content_admin = $this->drupalCreateUser(
array(
'view all revisions',

View file

@ -25,7 +25,7 @@ class NodeTranslationUITest extends ContentTranslationUITestBase {
'theme',
'route',
'timezone',
'url.path',
'url.path.parent',
'url.query_args:_wrapper_format',
'user'
];

View file

@ -49,7 +49,7 @@ class NodeTypeTest extends NodeTestBase {
$type_exists = (bool) NodeType::load($type->id());
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
// Login a test user.
// Log in a test user.
$web_user = $this->drupalCreateUser(array('create ' . $type->label() . ' content'));
$this->drupalLogin($web_user);

View file

@ -58,7 +58,7 @@ class NodeTypeTranslationTest extends WebTestBase {
'translate configuration',
);
// Create and login user.
// Create and log in user.
$this->adminUser = $this->drupalCreateUser($admin_permissions);
// Add languages.

View file

@ -172,7 +172,7 @@ class FrontPageTest extends ViewTestBase {
// When a user with sufficient permissions is logged in, views_ui adds
// contextual links to the homepage view. This verifies there are no errors.
\Drupal::service('module_installer')->install(array('views_ui'));
// Login root user with sufficient permissions.
// Log in root user with sufficient permissions.
$this->drupalLogin($this->rootUser);
// Test frontpage view.
$this->drupalGet('node');

View file

@ -59,4 +59,3 @@ class NodeRevisionWizardTest extends WizardTestBase {
}
}

View file

@ -5,9 +5,16 @@
*
* Available variables:
* - node: The node entity with limited access to object properties and methods.
Only "getter" methods (method names starting with "get", "has", or "is")
and a few common methods such as "id" and "label" are available. Calling
other methods (such as node.delete) will result in an exception.
* Only method names starting with "get", "has", or "is" and a few common
* methods such as "id", "label", and "bundle" are available. For example:
* - node.getCreatedTime() will return the node creation timestamp.
* - node.hasField('field_example') returns TRUE if the node bundle includes
* field_example. (This does not indicate the presence of a value in this
* field.)
* - node.isPublished() will return whether the node is published or not.
* Calling other methods, such as node.delete(), will result in an exception.
* See \Drupal\node\Entity\Node for a full list of public properties and
* methods for the node object.
* - label: The title of the node.
* - content: All node items. Use {{ content }} to print them all,
* or print a subset such as {{ content.field_example }}. Use

View file

@ -19,6 +19,7 @@
* @see \Drupal\node\Tests\NodeAccessBaseTableTest
*/
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
@ -144,7 +145,7 @@ function node_access_test_add_field(NodeTypeInterface $type) {
/**
* Implements hook_node_access().
*/
function node_access_test_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account) {
function node_access_test_node_access(NodeInterface $node, $op, AccountInterface $account) {
$secret_catalan = \Drupal::state()
->get('node_access_test_secret_catalan') ?: 0;
if ($secret_catalan && $node->language()->getId() == 'ca') {

View file

@ -8,6 +8,7 @@
* interaction with the Node module.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
@ -151,7 +152,7 @@ function node_test_node_update(NodeInterface $node) {
/**
* Implements hook_entity_view_mode_alter().
*/
function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
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') ?: '';
if ($change_view_mode) {

View file

@ -1,9 +1,9 @@
<?php
namespace Drupal\node\Tests\Config;
namespace Drupal\Tests\node\Kernel\Config;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Change content types during config create method invocation.

View file

@ -1,10 +1,10 @@
<?php
namespace Drupal\node\Tests\Config;
namespace Drupal\Tests\node\Kernel\Config;
use Drupal\field\Entity\FieldConfig;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Create content types during config create method invocation.
@ -59,8 +59,8 @@ class NodeImportCreateTest extends KernelTestBase {
$sync = $this->container->get('config.storage.sync');
$this->copyConfig($active, $sync);
// Manually add new node type.
$src_dir = drupal_get_path('module', 'node_test_config') . '/sync';
$target_dir = $this->configDirectories[CONFIG_SYNC_DIRECTORY];
$src_dir = __DIR__ . '/../../../modules/node_test_config/sync';
$target_dir = config_get_config_directory(CONFIG_SYNC_DIRECTORY);
$this->assertTrue(file_unmanaged_copy("$src_dir/$node_type_config_name.yml", "$target_dir/$node_type_config_name.yml"));
// Import the content of the sync directory.

View file

@ -1,11 +1,11 @@
<?php
namespace Drupal\node\Tests;
namespace Drupal\Tests\node\Kernel;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\NodeType;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests node body field storage.

View file

@ -1,17 +1,17 @@
<?php
namespace Drupal\node\Tests\Condition;
namespace Drupal\Tests\node\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
* Tests that conditions, provided by the node module, are working properly.
*
* @group node
*/
class NodeConditionTest extends EntityUnitTestBase {
class NodeConditionTest extends EntityKernelTestBase {
public static $modules = array('node');

View file

@ -1,18 +1,18 @@
<?php
namespace Drupal\node\Tests;
namespace Drupal\Tests\node\Kernel;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
* Tests node field level access.
*
* @group node
*/
class NodeFieldAccessTest extends EntityUnitTestBase {
class NodeFieldAccessTest extends EntityKernelTestBase {
/**
* Modules to enable.

View file

@ -1,18 +1,19 @@
<?php
namespace Drupal\node\Tests;
namespace Drupal\Tests\node\Kernel;
use Drupal\user\UserInterface;
use Drupal\Core\Field\Entity\BaseFieldOverride;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
* Tests node field overrides.
*
* @group node
*/
class NodeFieldOverridesTest extends EntityUnitTestBase {
class NodeFieldOverridesTest extends EntityKernelTestBase {
/**
* Current logged in user.
@ -56,7 +57,7 @@ class NodeFieldOverridesTest extends EntityUnitTestBase {
/** @var \Drupal\node\NodeInterface $node */
$node = Node::create(['type' => 'ponies']);
$owner = $node->getOwner();
$this->assertTrue($owner instanceof \Drupal\user\UserInterface);
$this->assertTrue($owner instanceof UserInterface);
$this->assertEqual($owner->id(), $this->user->id());
}

View file

@ -1,9 +1,9 @@
<?php
namespace Drupal\node\Tests;
namespace Drupal\Tests\node\Kernel;
use Drupal\Core\Language\LanguageInterface;
use Drupal\simpletest\KernelTestBase;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the admin listing fallback when views is not enabled.

View file

@ -1,18 +1,18 @@
<?php
namespace Drupal\node\Tests;
namespace Drupal\Tests\node\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
* Tests node owner functionality.
*
* @group Entity
*/
class NodeOwnerTest extends EntityUnitTestBase {
class NodeOwnerTest extends EntityKernelTestBase {
/**
* Modules to enable.

View file

@ -1,13 +1,13 @@
<?php
namespace Drupal\node\Tests;
namespace Drupal\Tests\node\Kernel;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Render\BubbleableMetadata;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\System\TokenReplaceUnitTestBase;
use Drupal\Tests\system\Kernel\Token\TokenReplaceKernelTestBase;
/**
* Generates text using placeholders for dummy content to check node token
@ -15,7 +15,7 @@ use Drupal\system\Tests\System\TokenReplaceUnitTestBase;
*
* @group node
*/
class NodeTokenReplaceTest extends TokenReplaceUnitTestBase {
class NodeTokenReplaceTest extends TokenReplaceKernelTestBase {
/**
* Modules to enable.

View file

@ -1,17 +1,17 @@
<?php
namespace Drupal\node\Tests;
namespace Drupal\Tests\node\Kernel;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\system\Tests\Entity\EntityUnitTestBase;
/**
* Tests node validation constraints.
*
* @group node
*/
class NodeValidationTest extends EntityUnitTestBase {
class NodeValidationTest extends EntityKernelTestBase {
/**
* Modules to enable.