9f7e41402c9c8087af5fd4b264c72ffa0b432a55
[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    * Tests an anonymous and unpermissioned user attempting to edit the node.
15    */
16   public function testPageView() {
17     // Create a node to view.
18     $node = $this->drupalCreateNode();
19     $this->assertTrue(Node::load($node->id()), 'Node created.');
20
21     // Try to edit with anonymous user.
22     $this->drupalGet("node/" . $node->id() . "/edit");
23     $this->assertResponse(403);
24
25     // Create a user without permission to edit node.
26     $web_user = $this->drupalCreateUser(['access content']);
27     $this->drupalLogin($web_user);
28
29     // Attempt to access edit page.
30     $this->drupalGet("node/" . $node->id() . "/edit");
31     $this->assertResponse(403);
32
33     // Create user with permission to edit node.
34     $web_user = $this->drupalCreateUser(['bypass node access']);
35     $this->drupalLogin($web_user);
36
37     // Attempt to access edit page.
38     $this->drupalGet("node/" . $node->id() . "/edit");
39     $this->assertResponse(200);
40   }
41
42 }