Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / node / tests / src / Functional / Views / FilterUidRevisionTest.php
1 <?php
2
3 namespace Drupal\Tests\node\Functional\Views;
4
5 use Drupal\views\Views;
6
7 /**
8  * Tests the node_uid_revision handler.
9  *
10  * @group node
11  */
12 class FilterUidRevisionTest extends NodeTestBase {
13
14   /**
15    * Views used by this test.
16    *
17    * @var array
18    */
19   public static $testViews = ['test_filter_node_uid_revision'];
20
21   /**
22    * Tests the node_uid_revision filter.
23    */
24   public function testFilter() {
25     $author = $this->drupalCreateUser();
26     $no_author = $this->drupalCreateUser();
27
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
33     // author.
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());
40     $revision->save();
41
42     // Create one  node on which the author has neither authorship of revisions
43     // or the main node.
44     $this->drupalCreateNode(['uid' => $no_author->id()]);
45
46     $view = Views::getView('test_filter_node_uid_revision');
47     $view->initHandlers();
48     $view->filter['uid_revision']->value = [$author->id()];
49
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.');
52   }
53
54 }