diff --git a/core/modules/views/lib/Drupal/views/Tests/Node/StatusExtraTest.php b/core/modules/views/lib/Drupal/views/Tests/Node/StatusExtraTest.php new file mode 100644 index 0000000000000000000000000000000000000000..4cade1e6f0e08efbc138e4d8649c3ddbb5a6b3c7 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Tests/Node/StatusExtraTest.php @@ -0,0 +1,83 @@ +<?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()); + } + +} diff --git a/core/modules/views/tests/views_test_config/config/views.view.test_status_extra.yml b/core/modules/views/tests/views_test_config/config/views.view.test_status_extra.yml new file mode 100644 index 0000000000000000000000000000000000000000..c0c582bd3d5274b30a50fa961f1d9f6665eabaa1 --- /dev/null +++ b/core/modules/views/tests/views_test_config/config/views.view.test_status_extra.yml @@ -0,0 +1,135 @@ +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 diff --git a/core/modules/views/views.module b/core/modules/views/views.module index 3234b7eccb4c15ee49feafbffeaea67f1a678dd2..cf10c1baa5a7d22091002527a3d3147a46c11b36 100644 --- a/core/modules/views/views.module +++ b/core/modules/views/views.module @@ -1112,6 +1112,9 @@ function views_hook_info() { $hooks['views_data'] = array( 'group' => 'views', ); + $hooks['views_query_substitutions'] = array( + 'group' => 'views', + ); return $hooks; } diff --git a/sites/default/default.settings.php b/sites/default/default.settings.php old mode 100644 new mode 100755 index 20f449092fe13613a2b3ea100576f5c68a2afe0f..44993edf1657f1cf6484419abf8cd0de4ca260be --- a/sites/default/default.settings.php +++ b/sites/default/default.settings.php @@ -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. *