Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176

This commit is contained in:
Pantheon Automation 2015-08-17 17:00:26 -07:00 committed by Greg Anderson
commit 9921556621
13277 changed files with 1459781 additions and 0 deletions

View file

@ -0,0 +1,6 @@
name: 'Node module access tests'
type: module
description: 'Support module for node permission testing.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,156 @@
<?php
/**
* @file
* Test module for testing the node access system.
*
* This module's functionality depends on the following state variables:
* - node_access_test.no_access_uid: Used in NodeQueryAlterTest to enable the
* node_access_all grant realm.
* - node_access_test.private: When TRUE, the module controls access for nodes
* with a 'private' property set, and inherits the default core access for
* nodes without this flag. When FALSE, the module controls access for all
* nodes.
* - node_access_test_secret_catalan: When set to TRUE and using the Catalan
* 'ca' language code, makes all Catalan content secret.
*
* @see node_access_test_node_grants()
* @see \Drupal\node\Tests\NodeQueryAlterTest
* @see \Drupal\node\Tests\NodeAccessBaseTableTest
*/
use Drupal\Core\Access\AccessResult;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\field\Entity\FieldConfig;
use Drupal\node\NodeTypeInterface;
use Drupal\node\NodeInterface;
/**
* Implements hook_node_grants().
*
* Provides three grant realms:
* - node_access_test_author: Grants users view, update, and delete privileges
* on nodes they have authored. Users receive a group ID matching their user
* ID on this realm.
* - node_access_test: Grants users view privileges when they have the
* 'node test view' permission. Users with this permission receive two group
* IDs for the realm, 8888 and 8889. Access for both realms is identical;
* the second group is added so that the interaction of multiple groups on
* a given grant realm can be tested in NodeAccessPagerTest.
* - node_access_all: Provides grants for the user whose user ID matches the
* 'node_access_test.no_access_uid' state variable. Access control on this
* realm is not provided in this module; instead,
* NodeQueryAlterTest::testNodeQueryAlterOverride() manually writes a node
* access record defining the access control for this realm.
*
* @see \Drupal\node\Tests\NodeQueryAlterTest::testNodeQueryAlterOverride()
* @see \Drupal\node\Tests\NodeAccessPagerTest
* @see node_access_test.permissions.yml
* @see node_access_test_node_access_records()
*/
function node_access_test_node_grants($account, $op) {
$grants = array();
$grants['node_access_test_author'] = array($account->id());
if ($op == 'view' && $account->hasPermission('node test view', $account)) {
$grants['node_access_test'] = array(8888, 8889);
}
$no_access_uid = \Drupal::state()->get('node_access_test.no_access_uid') ?: 0;
if ($op == 'view' && $account->id() == $no_access_uid) {
$grants['node_access_all'] = array(0);
}
return $grants;
}
/**
* Implements hook_node_access_records().
*
* By default, records are written for all nodes. When the
* 'node_access_test.private' state variable is set to TRUE, records
* are only written for nodes with a "private" property set, which causes the
* Node module to write the default global view grant for nodes that are not
* marked private.
*
* @see \Drupal\node\Tests\NodeAccessBaseTableTest::setUp()
* @see node_access_test_node_grants()
* @see node_access_test.permissions.yml
*/
function node_access_test_node_access_records(NodeInterface $node) {
$grants = array();
// For NodeAccessBaseTableTestCase, only set records for private nodes.
if (!\Drupal::state()->get('node_access_test.private') || $node->private->value) {
// Groups 8888 and 8889 for the node_access_test realm both receive a view
// grant for all controlled nodes. See node_access_test_node_grants().
$grants[] = array(
'realm' => 'node_access_test',
'gid' => 8888,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
$grants[] = array(
'realm' => 'node_access_test',
'gid' => 8889,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
// For the author realm, the group ID is equivalent to a user ID, which
// means there are many many groups of just 1 user.
$grants[] = array(
'realm' => 'node_access_test_author',
'gid' => $node->getOwnerId(),
'grant_view' => 1,
'grant_update' => 1,
'grant_delete' => 1,
'priority' => 0,
);
}
return $grants;
}
/**
* Adds the private field to a node type.
*
* @param \Drupal\node\NodeTypeInterface $type
* A node type entity.
*/
function node_access_test_add_field(NodeTypeInterface $type) {
$field_storage = FieldStorageConfig::create(array(
'field_name' => 'private',
'entity_type' => 'node',
'type' => 'integer',
));
$field_storage->save();
$field = FieldConfig::create(array(
'field_name' => 'private',
'entity_type' => 'node',
'bundle' => $type->id(),
'label' => 'Private',
));
$field->save();
// Assign widget settings for the 'default' form mode.
entity_get_form_display('node', $type->id(), 'default')
->setComponent('private', array(
'type' => 'number',
))
->save();
}
/**
* Implements hook_node_access().
*/
function node_access_test_node_access(\Drupal\node\NodeInterface $node, $op, \Drupal\Core\Session\AccountInterface $account, $langcode) {
$secret_catalan = \Drupal::state()
->get('node_access_test_secret_catalan') ?: 0;
if ($secret_catalan && $langcode == 'ca') {
// Make all Catalan content secret.
return AccessResult::forbidden()->setCacheMaxAge(0);
}
// No opinion.
return AccessResult::neutral()->setCacheMaxAge(0);
}

View file

@ -0,0 +1,2 @@
node test view:
title: 'View content'

View file

@ -0,0 +1,6 @@
name: 'Node module empty access tests'
type: module
description: 'Support module for node permission testing. Provides empty grants hook implementations.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,22 @@
<?php
/**
* @file
* Empty node access hook implementations.
*/
use Drupal\node\NodeInterface;
/**
* Implements hook_node_grants().
*/
function node_access_test_empty_node_grants($account, $op) {
return array();
}
/**
* Implements hook_node_access_records().
*/
function node_access_test_empty_node_access_records(NodeInterface $node) {
return array();
}

View file

@ -0,0 +1,8 @@
name: 'Node module access tests language'
type: module
description: 'Support module for language-aware node access testing.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- options

View file

@ -0,0 +1,44 @@
<?php
/**
* @file
* Test module with a language-aware node access implementation.
*
* The module adds a 'private' field to page nodes that allows each translation
* of the node to be marked as private (viewable only by administrators).
*/
use Drupal\node\NodeInterface;
/**
* Implements hook_node_grants().
*
* This module defines a single grant realm. All users belong to this group.
*/
function node_access_test_language_node_grants($account, $op) {
$grants['node_access_language_test'] = array(7888);
return $grants;
}
/**
* Implements hook_node_access_records().
*/
function node_access_test_language_node_access_records(NodeInterface $node) {
$grants = array();
// Create grants for each translation of the node.
foreach ($node->getTranslationLanguages() as $langcode => $language) {
// If the translation is not marked as private, grant access.
$translation = $node->getTranslation($langcode);
$grants[] = array(
'realm' => 'node_access_language_test',
'gid' => 7888,
'grant_view' => empty($translation->field_private->value) ? 1 : 0,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
'langcode' => $langcode,
);
}
return $grants;
}

View file

@ -0,0 +1,6 @@
name: 'Node module tests'
type: module
description: 'Support module for node related testing.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,175 @@
<?php
/**
* @file
* A dummy module for testing node related hooks.
*
* This is a dummy module that implements node related hooks to test API
* interaction with the Node module.
*/
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
/**
* Implements hook_ENTITY_TYPE_view() for node entities.
*/
function node_test_node_view(array &$build, NodeInterface $node, EntityViewDisplayInterface $display, $view_mode) {
if ($view_mode == 'rss') {
// Add RSS elements and namespaces when building the RSS feed.
$node->rss_elements[] = array(
'key' => 'testElement',
'value' => t('Value of testElement RSS element for node !nid.', array('!nid' => $node->id())),
);
// Add content that should be displayed only in the RSS feed.
$build['extra_feed_content'] = array(
'#markup' => '<p>' . t('Extra data that should appear only in the RSS feed for node !nid.', array('!nid' => $node->id())) . '</p>',
'#weight' => 10,
);
}
if ($view_mode != 'rss') {
// Add content that should NOT be displayed in the RSS feed.
$build['extra_non_feed_content'] = array(
'#markup' => '<p>' . t('Extra data that should appear everywhere except the RSS feed for node !nid.', array('!nid' => $node->id())) . '</p>',
);
}
}
/**
* Implements hook_ENTITY_TYPE_build_defaults_alter() for node entities.
*/
function node_test_node_build_defaults_alter(array &$build, NodeInterface &$node, $view_mode = 'full', $langcode = NULL) {
if ($view_mode == 'rss') {
$node->rss_namespaces['xmlns:drupaltest'] = 'http://example.com/test-namespace';
}
}
/**
* Implements hook_node_grants().
*/
function node_test_node_grants(AccountInterface $account, $op) {
// Give everyone full grants so we don't break other node tests.
// Our node access tests asserts three realms of access.
// See testGrantAlter().
return array(
'test_article_realm' => array(1),
'test_page_realm' => array(1),
'test_alter_realm' => array(2),
);
}
/**
* Implements hook_node_access_records().
*/
function node_test_node_access_records(NodeInterface $node) {
// Return nothing when testing for empty responses.
if (!empty($node->disable_node_access)) {
return;
}
$grants = array();
if ($node->getType() == 'article') {
// Create grant in arbitrary article_realm for article nodes.
$grants[] = array(
'realm' => 'test_article_realm',
'gid' => 1,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
elseif ($node->getType() == 'page') {
// Create grant in arbitrary page_realm for page nodes.
$grants[] = array(
'realm' => 'test_page_realm',
'gid' => 1,
'grant_view' => 1,
'grant_update' => 0,
'grant_delete' => 0,
'priority' => 0,
);
}
return $grants;
}
/**
* Implements hook_node_access_records_alter().
*/
function node_test_node_access_records_alter(&$grants, NodeInterface $node) {
if (!empty($grants)) {
foreach ($grants as $key => $grant) {
// Alter grant from test_page_realm to test_alter_realm and modify the gid.
if ($grant['realm'] == 'test_page_realm' && $node->isPromoted()) {
$grants[$key]['realm'] = 'test_alter_realm';
$grants[$key]['gid'] = 2;
}
}
}
}
/**
* Implements hook_node_grants_alter().
*/
function node_test_node_grants_alter(&$grants, AccountInterface $account, $op) {
// Return an empty array of grants to prove that we can alter by reference.
$grants = array();
}
/**
* Implements hook_ENTITY_TYPE_presave() for node entities.
*/
function node_test_node_presave(NodeInterface $node) {
if ($node->getTitle() == 'testing_node_presave') {
// Sun, 19 Nov 1978 05:00:00 GMT
$node->setCreatedTime(280299600);
// Drupal 1.0 release.
$node->changed = 979534800;
}
// Determine changes.
if (!empty($node->original) && $node->original->getTitle() == 'test_changes') {
if ($node->original->getTitle() != $node->getTitle()) {
$node->title->value .= '_presave';
}
}
}
/**
* Implements hook_ENTITY_TYPE_update() for node entities.
*/
function node_test_node_update(NodeInterface $node) {
// Determine changes on update.
if (!empty($node->original) && $node->original->getTitle() == 'test_changes') {
if ($node->original->getTitle() != $node->getTitle()) {
$node->title->value .= '_update';
}
}
}
/**
* Implements hook_entity_view_mode_alter().
*/
function node_test_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\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_mode = $change_view_mode;
}
}
/**
* Implements hook_ENTITY_TYPE_insert() for node entities.
*
* This tests saving a node on node insert.
*
* @see \Drupal\node\Tests\NodeSaveTest::testNodeSaveOnInsert()
*/
function node_test_node_insert(NodeInterface $node) {
// Set the node title to the node ID and save.
if ($node->getTitle() == 'new') {
$node->setTitle('Node '. $node->id());
$node->save();
}
}

View file

@ -0,0 +1,9 @@
type: default
name: Default
description: 'Default description.'
help: ''
new_revision: false
display_submitted: true
preview_mode: 1
status: true
langcode: en

View file

@ -0,0 +1,6 @@
name: 'Node configuration tests'
type: module
description: 'Support module for node configuration tests.'
core: 8.x
package: Testing
version: VERSION

View file

@ -0,0 +1,9 @@
type: import
name: Import
description: 'Import description.'
help: ''
new_revision: false
display_submitted: true
preview_mode: 1
status: true
langcode: en

View file

@ -0,0 +1,6 @@
name: 'Node module exception tests'
type: module
description: 'Support module for node related exception testing.'
package: Testing
version: VERSION
core: 8.x

View file

@ -0,0 +1,17 @@
<?php
/**
* @file
* A module implementing node related hooks to test API interaction.
*/
use Drupal\node\NodeInterface;
/**
* Implements hook_ENTITY_TYPE_insert() for node entities.
*/
function node_test_exception_node_insert(NodeInterface $node) {
if ($node->getTitle() == 'testing_transaction_exception') {
throw new Exception('Test exception for rollback.');
}
}

View file

@ -0,0 +1,10 @@
name: 'Node test views'
type: module
description: 'Provides default views for views node tests.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- node
- views
- language

View file

@ -0,0 +1,16 @@
<?php
/**
* @file
* Provides views data and hooks for node_test_views module.
*/
/**
* Implements hook_views_data_alter().
*/
function node_test_views_views_data_alter(array &$data) {
// Make node language use the basic field handler if requested.
if (\Drupal::state()->get('node_test_views.use_basic_handler')) {
$data['node_field_data']['langcode']['field']['id'] = 'language';
}
}

View file

@ -0,0 +1,99 @@
langcode: en
status: true
dependencies:
module:
- node
- user
id: test_contextual_links
label: 'Contextual links'
module: node
description: ''
tag: default
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: '« first'
last: 'last »'
quantity: 9
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
row:
type: 'entity:node'
options:
view_mode: teaser
style:
type: default
options:
grouping: { }
row_class: ''
default_row_class: true
uses_fields: false
title: ''
header: { }
footer: { }
relationships: { }
fields: { }
arguments: { }
display_plugin: default
display_title: Master
id: default
position: 0
page_1:
display_options:
path: node/%/contextual-links
defaults:
arguments: false
arguments:
nid:
field: nid
id: nid
relationship: none
table: node_field_data
plugin_id: numeric
entity_type: node
entity_field: nid
menu:
type: tab
title: 'Test contextual link'
description: ''
menu_name: tools
weight: 0
context: '1'
display_plugin: page
display_title: Page
id: page_1
position: 1

View file

@ -0,0 +1,376 @@
langcode: en
status: true
dependencies:
module:
- node
- user
id: test_field_filters
label: 'Test field filters'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: none
options:
items_per_page: 0
offset: 0
style:
type: default
row:
type: 'entity:node'
options:
view_mode: teaser
fields:
title:
id: title
table: node_field_data
field: title
label: ''
alter:
alter_text: false
make_link: false
absolute: false
trim: false
word_boundary: false
ellipsis: false
strip_tags: false
html: false
hide_empty: false
empty_zero: false
relationship: none
group_type: group
admin_label: ''
exclude: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_alter_empty: true
entity_type: node
entity_field: title
plugin_id: field
filters:
status:
value: true
table: node_field_data
field: status
id: status
expose:
operator: ''
group: 1
plugin_id: boolean
entity_type: node
entity_field: status
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Paris
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
entity_type: node
entity_field: title
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
plugin_id: date
entity_type: node
entity_field: created
title: 'Test field filters'
header: { }
footer: { }
empty: { }
relationships: { }
arguments: { }
rendering_language: '***LANGUAGE_entity_translation***'
page_bf:
display_plugin: page
id: page_bf
display_title: 'Body filter page'
position: 1
display_options:
path: test-body-filter
display_description: ''
title: 'Test body filters'
defaults:
title: false
filters: false
filter_groups: false
filters:
status:
value: true
table: node_field_data
field: status
id: status
expose:
operator: ''
group: 1
plugin_id: boolean
entity_type: node
entity_field: status
body_value:
id: body_value
table: node__body
field: body_value
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Comida
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
entity_type: node
entity_field: body
filter_groups:
operator: AND
groups:
1: AND
page_bfp:
display_plugin: page
id: page_bfp
display_title: 'Body filter page Paris'
position: 1
display_options:
path: test-body-paris
display_description: ''
title: 'Test body filters'
defaults:
title: false
filters: false
filter_groups: false
filters:
status:
value: true
table: node_field_data
field: status
id: status
expose:
operator: ''
group: 1
entity_type: node
entity_field: status
plugin_id: boolean
body_value:
id: body_value
table: node__body
field: body_value
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Paris
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
entity_type: node
entity_field: body
filter_groups:
operator: AND
groups:
1: AND
page_tf:
display_plugin: page
id: page_tf
display_title: 'Title filter page'
position: 1
display_options:
path: test-title-filter
display_description: ''
title: 'Test title filter'
defaults:
title: false
filters: false
filter_groups: false
filters:
status:
value: true
table: node_field_data
field: status
id: status
expose:
operator: ''
group: 1
entity_type: node
entity_field: status
plugin_id: boolean
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
operator: contains
value: Comida
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: string
entity_type: node
entity_field: title
filter_groups:
operator: AND
groups:
1: AND
page_tfp:
display_plugin: page
id: page_tfp
display_title: 'Title filter page Paris'
position: 1
display_options:
path: test-title-paris
display_description: ''
title: 'Test title filter'
defaults:
title: false

View file

@ -0,0 +1,71 @@
langcode: en
status: true
dependencies:
module:
- node
- user
id: test_filter_node_uid_revision
label: test_filter_node_uid_revision
module: views
description: ''
tag: default
base_table: node_field_data
base_field: nid
core: 8.0-dev
display:
default:
display_options:
access:
type: perm
cache:
type: tag
exposed_form:
type: basic
fields:
nid:
id: nid
table: node_field_data
field: nid
plugin_id: field
entity_type: node
entity_field: nid
filter_groups:
groups:
1: AND
operator: AND
filters:
uid_revision:
admin_label: ''
field: uid_revision
id: uid_revision
is_grouped: false
operator: in
relationship: none
table: node_field_data
value:
- '1'
plugin_id: node_uid_revision
entity_type: node
entity_field: uid_revision
sorts:
nid:
id: nid
table: node_field_data
field: nid
order: ASC
plugin_id: standard
relationship: none
entity_type: node
entity_field: nid
pager:
type: full
query:
type: views_query
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default
position: 0

View file

@ -0,0 +1,291 @@
langcode: en
status: true
dependencies:
module:
- node
- user
id: test_language
label: 'Test language'
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: none
options:
items_per_page: 0
offset: 0
style:
type: default
row:
type: fields
options:
default_field_elements: true
inline: { }
separator: ''
hide_empty: false
fields:
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: false
ellipsis: false
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: field
entity_type: node
entity_field: title
langcode:
id: langcode
table: node_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
label: Language
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: field
entity_type: node
entity_field: langcode
settings:
native_language: false
type: language
filters:
status:
value: true
table: node_field_data
field: status
id: status
expose:
operator: ''
group: 1
plugin_id: boolean
entity_type: node
entity_field: status
type:
id: type
table: node_field_data
field: type
value:
page: page
plugin_id: bundle
entity_type: node
entity_field: type
langcode:
id: langcode
table: node_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
operator: in
value:
fr: fr
es: es
group: 1
exposed: false
expose:
operator_id: ''
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
reduce: false
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: language
entity_type: node
entity_field: langcode
sorts:
langcode:
id: langcode
table: node_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
order: ASC
exposed: false
expose:
label: ''
plugin_id: standard
entity_type: node
entity_field: langcode
title: 'Language filter test'
header: { }
footer: { }
empty: { }
relationships: { }
arguments:
langcode:
id: langcode
table: node_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
default_action: ignore
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: fixed
default_argument_options:
argument: ''
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
plugin_id: language
entity_type: node
entity_field: langcode
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
path: test-language

View file

@ -0,0 +1,69 @@
langcode: en
status: true
dependencies:
module:
- node
id: test_node_bulk_form
label: ''
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: null
display_options:
style:
type: table
row:
type: fields
fields:
node_bulk_form:
id: node_bulk_form
table: node
field: node_bulk_form
plugin_id: node_bulk_form
entity_type: node
title:
id: title
table: node_field_data
field: title
plugin_id: field
entity_type: node
entity_field: title
sorts:
nid:
id: nid
table: node_field_data
field: nid
order: ASC
plugin_id: standard
entity_type: node
entity_field: nid
langcode:
id: langcode
table: node_field_data
field: langcode
relationship: none
group_type: group
admin_label: ''
order: ASC
exposed: false
expose:
label: ''
entity_type: node
entity_field: langcode
plugin_id: standard
display_extenders: { }
page_1:
display_plugin: page
id: page_1
display_title: Page
position: null
display_options:
path: test-node-bulk-form

View file

@ -0,0 +1,58 @@
langcode: en
status: true
dependencies:
module:
- node
id: test_node_revision_nid
label: null
module: views
description: ''
tag: ''
base_table: node_field_revision
base_field: nid
core: '8'
display:
default:
display_options:
relationships:
nid:
id: nid
table: node_field_revision
field: nid
required: true
plugin_id: field
fields:
vid:
id: vid
table: node_field_revision
field: vid
plugin_id: field
entity_type: node
entity_field: vid
nid_1:
id: nid_1
table: node_field_revision
field: nid
plugin_id: field
entity_type: node
entity_field: nid
nid:
id: nid
table: node_field_data
field: nid
relationship: nid
plugin_id: field
entity_type: node
entity_field: nid
arguments:
nid:
id: nid
table: node_field_revision
field: nid
plugin_id: node_nid
entity_type: node
entity_field: nid
display_plugin: default
display_title: Master
id: default
position: 0

View file

@ -0,0 +1,58 @@
langcode: en
status: true
dependencies:
module:
- node
id: test_node_revision_vid
label: null
module: views
description: ''
tag: ''
base_table: node_field_revision
base_field: nid
core: '8'
display:
default:
display_options:
relationships:
vid:
id: vid
table: node_field_revision
field: vid
required: true
plugin_id: standard
fields:
vid:
id: vid
table: node_field_revision
field: vid
plugin_id: field
entity_type: node
entity_field: vid
nid_1:
id: nid_1
table: node_field_revision
field: nid
plugin_id: field
entity_type: node
entity_field: nid
nid:
id: nid
table: node_field_data
field: nid
relationship: vid
plugin_id: field
entity_type: node
entity_field: nid
arguments:
nid:
id: nid
table: node_field_revision
field: nid
plugin_id: node_nid
entity_type: node
entity_field: nid
display_plugin: default
display_title: Master
id: default
position: 0

View file

@ -0,0 +1,60 @@
langcode: en
status: true
dependencies:
module:
- node
- user
id: test_node_row_plugin
label: test_node_row_plugin
module: views
description: ''
tag: default
base_table: node_field_data
base_field: nid
core: '8'
display:
default:
display_options:
access:
type: perm
cache:
type: tag
exposed_form:
type: basic
filters:
status:
expose:
operator: ''
field: status
group: 1
id: status
table: node_field_data
value: true
plugin_id: boolean
entity_type: node
entity_field: status
pager:
options:
items_per_page: 10
type: full
query:
type: views_query
row:
options:
view_mode: teaser
type: 'entity:node'
sorts: { }
style:
type: default
title: test_node_row_plugin
display_plugin: default
display_title: Master
id: default
position: 0
page_1:
display_options:
path: test-node-row-plugin
display_plugin: page
display_title: Page
id: page_1
position: 0

View file

@ -0,0 +1,205 @@
langcode: en
status: true
dependencies:
module:
- node
- user
id: test_node_view
label: test_node_view
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: null
display_options:
access:
type: perm
options:
perm: 'access content'
cache:
type: tag
options: { }
query:
type: views_query
options:
disable_sql_rewrite: false
distinct: false
replica: false
query_comment: ''
query_tags: { }
exposed_form:
type: basic
options:
submit_button: Apply
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next '
first: '« first'
last: 'last »'
quantity: 9
style:
type: default
row:
type: fields
fields:
nid:
id: nid
table: node_field_data
field: nid
relationship: none
group_type: group
admin_label: ''
label: Nid
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: field
entity_type: node
entity_field: nid
filters:
status:
value: true
table: node_field_data
field: status
id: status
expose:
operator: ''
group: 1
plugin_id: boolean
entity_type: node
entity_field: status
sorts:
created:
id: created
table: node_field_data
field: created
order: DESC
relationship: none
group_type: group
admin_label: ''
exposed: false
expose:
label: ''
granularity: second
plugin_id: date
entity_type: node
entity_field: created
title: test_node_view
header: { }
footer: { }
empty: { }
relationships: { }
arguments:
type:
id: type
table: node_field_data
field: type
relationship: none
group_type: group
admin_label: ''
default_action: 'not found'
exception:
value: all
title_enable: false
title: All
title_enable: false
title: ''
default_argument_type: fixed
default_argument_options:
argument: ''
default_argument_skip_url: false
summary_options:
base_path: ''
count: true
items_per_page: 25
override: false
summary:
sort_order: asc
number_of_records: 0
format: default_summary
specify_validation: false
validate:
type: none
fail: 'not found'
validate_options: { }
glossary: false
limit: 0
case: none
path_case: none
transform_dash: false
break_phrase: false
plugin_id: node_type
entity_type: node
entity_field: type
page_1:
display_plugin: page
id: page_1
display_title: Page
position: null
display_options:
path: test-node-view

View file

@ -0,0 +1,145 @@
langcode: en
status: true
dependencies:
module:
- node
- user
id: test_status_extra
label: test_status_extra
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
default:
display_plugin: default
id: default
display_title: Master
position: null
display_options:
access:
type: perm
cache:
type: tag
query:
type: views_query
exposed_form:
type: basic
pager:
type: full
style:
type: default
row:
type: fields
fields:
title:
id: title
table: node_field_data
field: title
relationship: none
group_type: group
admin_label: ''
label: Title
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
plugin_id: field
entity_type: node
entity_field: title
filters:
status_extra:
id: status_extra
table: node_field_data
field: status_extra
relationship: none
group_type: group
admin_label: ''
operator: '='
value: false
group: 1
exposed: false
expose:
operator_id: '0'
label: ''
description: ''
use_operator: false
operator: ''
identifier: ''
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
plugin_id: node_status
entity_type: node
sorts:
nid:
id: nid
table: node_field_data
field: nid
order: ASC
plugin_id: standard
entity_type: node
entity_field: nid
filter_groups:
operator: AND
groups:
1: AND
page_1:
display_options:
path: test_status_extra
display_plugin: page
display_title: Page
id: page_1
position: 0

View file

@ -0,0 +1,90 @@
<?php
/**
* @file
* Contains \Drupal\Tests\node\Unit\PageCache\DenyNodePreviewTest.
*/
namespace Drupal\Tests\node\Unit\PageCache;
use Drupal\Core\PageCache\ResponsePolicyInterface;
use Drupal\node\PageCache\DenyNodePreview;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* @coversDefaultClass \Drupal\node\PageCache\DenyNodePreview
* @group node
*/
class DenyNodePreviewTest extends UnitTestCase {
/**
* The response policy under test.
*
* @var \Drupal\node\PageCache\DenyNodePreview
*/
protected $policy;
/**
* A request object.
*
* @var \Symfony\Component\HttpFoundation\Request
*/
protected $request;
/**
* A response object.
*
* @var \Symfony\Component\HttpFoundation\Response
*/
protected $response;
/**
* The current route match.
*
* @var \Drupal\Core\Routing\RouteMatch|\PHPUnit_Framework_MockObject_MockObject
*/
protected $routeMatch;
public function setUp() {
$this->routeMatch = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
$this->policy = new DenyNodePreview($this->routeMatch);
$this->response = new Response();
$this->request = new Request();
}
/**
* Asserts that caching is denied on the node preview route.
*
* @dataProvider providerPrivateImageStyleDownloadPolicy
* @covers ::check
*/
public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
$this->routeMatch->expects($this->once())
->method('getRouteName')
->will($this->returnValue($route_name));
$actual_result = $this->policy->check($this->response, $this->request);
$this->assertSame($expected_result, $actual_result);
}
/**
* Provides data and expected results for the test method.
*
* @return array
* Data and expected results.
*/
public function providerPrivateImageStyleDownloadPolicy() {
return [
[ResponsePolicyInterface::DENY, 'entity.node.preview'],
[NULL, 'some.other.route'],
[NULL, NULL],
[NULL, FALSE],
[NULL, TRUE],
[NULL, new \StdClass()],
[NULL, [1, 2, 3]],
];
}
}

View file

@ -0,0 +1,98 @@
<?php
/**
* @file
* Contains \Drupal\Tests\node\Unit\Plugin\views\field\NodeBulkFormTest.
*/
namespace Drupal\Tests\node\Unit\Plugin\views\field;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\node\Plugin\views\field\NodeBulkForm;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\node\Plugin\views\field\NodeBulkForm
* @group node
*/
class NodeBulkFormTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
protected function tearDown() {
parent::tearDown();
$container = new ContainerBuilder();
\Drupal::setContainer($container);
}
/**
* Tests the constructor assignment of actions.
*/
public function testConstructor() {
$actions = array();
for ($i = 1; $i <= 2; $i++) {
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('node'));
$actions[$i] = $action;
}
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
$action->expects($this->any())
->method('getType')
->will($this->returnValue('user'));
$actions[] = $action;
$entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
$entity_storage->expects($this->any())
->method('loadMultiple')
->will($this->returnValue($actions));
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
$entity_manager->expects($this->once())
->method('getStorage')
->with('action')
->will($this->returnValue($entity_storage));
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
$views_data = $this->getMockBuilder('Drupal\views\ViewsData')
->disableOriginalConstructor()
->getMock();
$views_data->expects($this->any())
->method('get')
->with('node')
->will($this->returnValue(array('table' => array('entity type' => 'node'))));
$container = new ContainerBuilder();
$container->set('views.views_data', $views_data);
$container->set('string_translation', $this->getStringTranslationStub());
\Drupal::setContainer($container);
$storage = $this->getMock('Drupal\views\ViewEntityInterface');
$storage->expects($this->any())
->method('get')
->with('base_table')
->will($this->returnValue('node'));
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
->disableOriginalConstructor()
->getMock();
$executable->storage = $storage;
$display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
->disableOriginalConstructor()
->getMock();
$definition['title'] = '';
$options = array();
$node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_manager, $language_manager);
$node_bulk_form->init($executable, $display, $options);
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form);
}
}