3 namespace Drupal\Tests\diff\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests the diff overview form with modules implementing node access.
12 class NodeAccessTest extends BrowserTestBase {
17 public static $modules = ['diff', 'node', 'node_access_test'];
22 protected function setUp() {
25 $this->createContentType(['type' => 'article']);
31 node_access_rebuild();
35 * Tests that the revision overview form still works with node access.
37 public function testOverview() {
38 // Create an unpublished node with 3 revisions.
39 $node = $this->createNode([
43 $node->setTitle($this->randomString());
44 $node->setNewRevision();
46 $node->setTitle($this->randomString());
47 $node->setNewRevision();
49 $user = $this->createUser(['access content', 'view all revisions']);
50 $this->drupalLogin($user);
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());
56 $this->drupalGet($node->toUrl());
57 $this->assertSession()->statusCodeEquals(200);
58 $this->drupalGet($node->toUrl('version-history'));
59 $this->assertSession()->statusCodeEquals(200);
61 // There should be 3 diff rows.
62 $rows = $this->xpath('//tbody/tr');
63 $this->assertCount(3, $rows, 'Did not find 3 diff rows.');
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);