Commit cf22d23b authored by dawehner's avatar dawehner Committed by tim.plunkett

Issue #1777512 by dawehner: Fixed UidRevision filter handler uses undefined variable.

parent 206cd481
......@@ -5,6 +5,8 @@
* Handles the server side AJAX interactions of Views.
*/
use Symfony\Component\HttpFoundation\JsonResponse;
/**
* @defgroup ajax Views AJAX library
* @{
......
<?php
/**
* @file
* Definition of Drupal\views\Tests\Comment\FilterUidRevisionTest.
*/
namespace Drupal\views\Tests\Node;
/**
* Tests the node_uid_revision handler.
*/
class FilterUidRevisionTest extends NodeTestBase {
public static function getInfo() {
return array(
'name' => 'Node: User has revision Filter',
'description' => 'Tests the node_uid_revision handler.',
'group' => 'Views Modules',
);
}
/**
* Tests the node_uid_revision filter.
*/
public function testFilter() {
$author = $this->drupalCreateUser();
$no_author = $this->drupalCreateUser();
$expected_result = array();
// Create one node, with the author as the node author.
$node = $this->drupalCreateNode(array('uid' => $author->id()));
$expected_result[] = array('nid' => $node->id());
// Create one node of which an additional revision author will be the
// author.
$node = $this->drupalCreateNode(array('uid' => $no_author->id()));
$expected_result[] = array('nid' => $node->id());
$revision = clone $node;
// Force to add a new revision.
$revision->set('vid', NULL);
$revision->set('revision_uid', $author->id());
$revision->save();
// Create one node on which the author has neither authorship of revisions
// or the main node.
$node = $this->drupalCreateNode(array('uid' => $no_author->id()));
$view = views_get_view('test_filter_node_uid_revision');
$view->initDisplay();
$view->initHandlers();
$view->filter['uid_revision']->value = array($author->uid);
$this->executeView($view);
$this->assertIdenticalResultset($view, $expected_result, array('nid' => 'nid'), 'Make sure that the view only returns nodes which match either the node or the revision author.');
}
}
<?php
/**
* @file
* Definition of Drupal\views\Tests\Node\NodeTestBase.
*/
namespace Drupal\views\Tests\Node;
use Drupal\views\Tests\ViewTestBase;
/**
* Base class for all node tests.
*/
abstract class NodeTestBase extends ViewTestBase {
}
......@@ -29,7 +29,7 @@ public function query($group_by = FALSE) {
$args = array_values($this->value);
$this->query->add_where_expression($this->options['group'], "$this->table_alias.uid IN($placeholder) " . $condition . " OR
$this->query->add_where_expression($this->options['group'], "$this->table_alias.uid IN($placeholder) OR
((SELECT COUNT(*) FROM {node_revision} nr WHERE nr.uid IN($placeholder) AND nr.nid = $this->table_alias.nid) > 0)", array($placeholder => $args),
$args);
}
......
api_version: '3.0'
base_table: node
core: 8.0-dev
description: ''
disabled: '0'
display:
default:
display_options:
access:
type: perm
cache:
type: none
exposed_form:
type: basic
fields:
nid:
id: nid
table: node
field: nid
filter_groups:
groups:
1: AND
operator: AND
filters:
uid_revision:
admin_label: ''
field: uid_revision
id: uid_revision
is_grouped: '0'
operator: in
relationship: none
table: node
value:
- '1'
sorts:
nid:
id: nid
table: node
field: nid
order: asc
pager:
type: full
query:
type: views_query
row_plugin: fields
sorts: { }
style_plugin: default
display_plugin: default
display_title: Master
id: default
position: '0'
human_name: test_filter_node_uid_revision
name: test_filter_node_uid_revision
tag: default
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