3 namespace Drupal\Tests\node\Functional\Views;
5 use Drupal\views\Views;
8 * Tests the node_uid_revision handler.
12 class FilterUidRevisionTest extends NodeTestBase {
15 * Views used by this test.
19 public static $testViews = ['test_filter_node_uid_revision'];
22 * Tests the node_uid_revision filter.
24 public function testFilter() {
25 $author = $this->drupalCreateUser();
26 $no_author = $this->drupalCreateUser();
28 $expected_result = [];
29 // Create one node, with the author as the node author.
30 $node = $this->drupalCreateNode(['uid' => $author->id()]);
31 $expected_result[] = ['nid' => $node->id()];
32 // Create one node of which an additional revision author will be the
34 $node = $this->drupalCreateNode(['revision_uid' => $no_author->id()]);
35 $expected_result[] = ['nid' => $node->id()];
36 $revision = clone $node;
37 // Force to add a new revision.
38 $revision->set('vid', NULL);
39 $revision->set('revision_uid', $author->id());
42 // Create one node on which the author has neither authorship of revisions
44 $this->drupalCreateNode(['uid' => $no_author->id()]);
46 $view = Views::getView('test_filter_node_uid_revision');
47 $view->initHandlers();
48 $view->filter['uid_revision']->value = [$author->id()];
50 $this->executeView($view);
51 $this->assertIdenticalResultset($view, $expected_result, ['nid' => 'nid'], 'Make sure that the view only returns nodes which match either the node or the revision author.');