Commit 53c73ccf authored by webchick's avatar webchick

Issue #1828612 by dawehner, damiankloip: Fixed...

Issue #1828612 by dawehner, damiankloip: Fixed hook_views_query_substitutions() missing from hook_hook_info().
parent e318f1a6
<?php
/**
* @file
* Contains \Drupal\views\Tests\Node\StatusExtraTest.
*/
namespace Drupal\views\Tests\Node;
/**
* Tests the node.status_extra field handler.
*
* @see \Drupal\node\Plugin\views\filter\Status
*/
class StatusExtraTest extends NodeTestBase {
public static function getInfo() {
return array(
'name' => 'Node: Status extra filter',
'description' => 'Tests the node.status_extra filter handler.',
'group' => 'Views Modules',
);
}
/**
* Tests the status extra filter.
*/
public function testStatusExtra() {
// @todo For whatever reason the menu has to be rebuilt or drupalGet will
// fail.
state()->set('menu_rebuild_needed', TRUE);
$column_map = array('nid' => 'nid');
$node_author = $this->drupalCreateUser(array('view own unpublished content'));
$node_author_not_unpublished = $this->drupalCreateUser();
$normal_user = $this->drupalCreateUser();
$admin_user = $this->drupalCreateUser(array('bypass node access'));
// Create one published and one unpublished node by the admin.
$node_published = $this->drupalCreateNode(array('uid' => $admin_user->id()));
$node_unpublished = $this->drupalCreateNode(array('uid' => $admin_user->id(), 'status' => NODE_NOT_PUBLISHED));
// Create one unpublished node by a certain author user.
$node_unpublished2 = $this->drupalCreateNode(array('uid' => $node_author->id(), 'status' => NODE_NOT_PUBLISHED));
// Create one unpublished node by a user who does not have the `view own
// unpublished content` permission.
$node_unpublished3 = $this->drupalCreateNode(array('uid' => $node_author_not_unpublished->id(), 'status' => NODE_NOT_PUBLISHED));
// The administrator should simply see all nodes.
$this->drupalLogin($admin_user);
$this->drupalGet('test_status_extra');
$this->assertText($node_published->label());
$this->assertText($node_unpublished->label());
$this->assertText($node_unpublished2->label());
$this->assertText($node_unpublished3->label());
// The node author should see the published node and his own node.
$this->drupalLogin($node_author);
$this->drupalGet('test_status_extra');
$this->assertText($node_published->label());
$this->assertNoText($node_unpublished->label());
$this->assertText($node_unpublished2->label());
$this->assertNoText($node_unpublished3->label());
// The normal user should just see the published node.
$this->drupalLogin($normal_user);
$this->drupalGet('test_status_extra');
$this->assertText($node_published->label());
$this->assertNoText($node_unpublished->label());
$this->assertNoText($node_unpublished2->label());
$this->assertNoText($node_unpublished3->label());
// The author without the permission to see his own unpublished node should
// just see the published node.
$this->drupalLogin($node_author_not_unpublished);
$this->drupalGet('test_status_extra');
$this->assertText($node_published->label());
$this->assertNoText($node_unpublished->label());
$this->assertNoText($node_unpublished2->label());
$this->assertNoText($node_unpublished3->label());
}
}
base_table: node
name: test_status_extra
description: ''
tag: ''
human_name: test_status_extra
core: 8.x
api_version: '3.0'
display:
default:
display_plugin: default
id: default
display_title: Master
position: ''
display_options:
access:
type: perm
cache:
type: none
query:
type: views_query
exposed_form:
type: basic
pager:
type: full
style:
type: default
row:
type: fields
fields:
title:
id: title
table: node
field: title
relationship: none
group_type: group
admin_label: ''
label: Title
exclude: '0'
alter:
alter_text: '0'
text: ''
make_link: '0'
path: ''
absolute: '0'
external: '0'
replace_spaces: '0'
path_case: none
trim_whitespace: '0'
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: '0'
max_length: ''
word_boundary: '1'
ellipsis: '1'
more_link: '0'
more_link_text: ''
more_link_path: ''
strip_tags: '0'
trim: '0'
preserve_tags: ''
html: '0'
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: '1'
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: '1'
empty: ''
hide_empty: '0'
empty_zero: '0'
hide_alter_empty: '1'
link_to_node: '0'
filters:
status_extra:
id: status_extra
table: node
field: status_extra
relationship: none
group_type: group
admin_label: ''
operator: '='
value: ''
group: '1'
exposed: '0'
expose:
operator_id: '0'
label: ''
description: ''
use_operator: '0'
operator: ''
identifier: ''
required: '0'
remember: '0'
multiple: '0'
remember_roles:
authenticated: authenticated
is_grouped: '0'
group_info:
label: ''
description: ''
identifier: ''
optional: '1'
widget: select
multiple: '0'
remember: '0'
default_group: All
default_group_multiple: { }
group_items: { }
sorts:
nid:
id: nid
table: node
field: nid
order: ASC
filter_groups:
operator: AND
groups:
1: AND
page_1:
display_options:
path: test_status_extra
display_plugin: page
display_title: Page
id: page
position: '0'
base_field: nid
disabled: '0'
module: views
langcode: und
......@@ -1112,6 +1112,9 @@ function views_hook_info() {
$hooks['views_data'] = array(
'group' => 'views',
);
$hooks['views_query_substitutions'] = array(
'group' => 'views',
);
return $hooks;
}
......
......@@ -149,7 +149,7 @@
* 'authmap' => 'shared_',
* ),
* @endcode
* You can also use a reference to a schema/database as a prefix. This may be
* You can also use a reference to a schema/database as a prefix. This maybe
* useful if your Drupal installation exists in a schema that is not the default
* or you want to access several databases from the same code base at the same
* time.
......@@ -464,7 +464,7 @@
/**
* String overrides:
*
* To override specific strings on your site with or without enabling the Locale
* To override specific strings on your site with or without enabling locale
* module, add an entry to this list. This functionality allows you to change
* a small number of your site's default English language interface strings.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment