Added Entity and Entity Reference Revisions which got dropped somewhere along the...
[yaffs-website] / web / core / modules / node / tests / src / Functional / PageViewTest.php
1 <?php
2
3 namespace Drupal\Tests\node\Functional;
4
5 use Drupal\node\Entity\Node;
6
7 /**
8  * Create a node and test edit permissions.
9  *
10  * @group node
11  */
12 class PageViewTest extends NodeTestBase {
13
14   /**
15    * Tests an anonymous and unpermissioned user attempting to edit the node.
16    */
17   public function testPageView() {
18     // Create a node to view.
19     $node = $this->drupalCreateNode();
20     $this->assertTrue(Node::load($node->id()), 'Node created.');
21
22     // Try to edit with anonymous user.
23     $this->drupalGet("node/" . $node->id() . "/edit");
24     $this->assertResponse(403);
25
26     // Create a user without permission to edit node.
27     $web_user = $this->drupalCreateUser(['access content']);
28     $this->drupalLogin($web_user);
29
30     // Attempt to access edit page.
31     $this->drupalGet("node/" . $node->id() . "/edit");
32     $this->assertResponse(403);
33
34     // Create user with permission to edit node.
35     $web_user = $this->drupalCreateUser(['bypass node access']);
36     $this->drupalLogin($web_user);
37
38     // Attempt to access edit page.
39     $this->drupalGet("node/" . $node->id() . "/edit");
40     $this->assertResponse(200);
41   }
42
43 }