Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / diff / tests / src / Functional / NodeAccessTest.php
1 <?php
2
3 namespace Drupal\Tests\diff\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests the diff overview form with modules implementing node access.
9  *
10  * @group diff
11  */
12 class NodeAccessTest extends BrowserTestBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public static $modules = ['diff', 'node', 'node_access_test'];
18
19   /**
20    * {@inheritdoc}
21    */
22   protected function setUp() {
23     parent::setUp();
24
25     $this->createContentType(['type' => 'article']);
26
27     // Dummy user 1.
28     $this->createUser();
29
30     // Rebuild access.
31     node_access_rebuild();
32   }
33
34   /**
35    * Tests that the revision overview form still works with node access.
36    */
37   public function testOverview() {
38     // Create an unpublished node with 3 revisions.
39     $node = $this->createNode([
40       'type' => 'article',
41       'status' => FALSE,
42     ]);
43     $node->setTitle($this->randomString());
44     $node->setNewRevision();
45     $node->save();
46     $node->setTitle($this->randomString());
47     $node->setNewRevision();
48     $node->save();
49     $user = $this->createUser(['access content', 'view all revisions']);
50     $this->drupalLogin($user);
51
52     // Grant access via node_access_test.
53     // @see node_access_test_node_access
54     \Drupal::state()->set('node_access_test.allow_uid', $user->id());
55
56     $this->drupalGet($node->toUrl());
57     $this->assertSession()->statusCodeEquals(200);
58     $this->drupalGet($node->toUrl('version-history'));
59     $this->assertSession()->statusCodeEquals(200);
60
61     // There should be 3 diff rows.
62     $rows = $this->xpath('//tbody/tr');
63     $this->assertCount(3, $rows, 'Did not find 3 diff rows.');
64
65     // Compare selected revisions should not time out.
66     $this->drupalGet('/node/' . $node->id(). '/revisions');
67     $this->drupalPostForm(NULL, NULL, t('Compare selected revisions'));
68     $this->assertSession()->statusCodeEquals(200);
69   }
70
71 }