3 namespace Drupal\Tests\node\Functional;
5 use Drupal\node\Entity\Node;
8 * Create a node and test edit permissions.
12 class PageViewTest extends NodeTestBase {
14 * Tests an anonymous and unpermissioned user attempting to edit the node.
16 public function testPageView() {
17 // Create a node to view.
18 $node = $this->drupalCreateNode();
19 $this->assertTrue(Node::load($node->id()), 'Node created.');
21 // Try to edit with anonymous user.
22 $this->drupalGet("node/" . $node->id() . "/edit");
23 $this->assertResponse(403);
25 // Create a user without permission to edit node.
26 $web_user = $this->drupalCreateUser(['access content']);
27 $this->drupalLogin($web_user);
29 // Attempt to access edit page.
30 $this->drupalGet("node/" . $node->id() . "/edit");
31 $this->assertResponse(403);
33 // Create user with permission to edit node.
34 $web_user = $this->drupalCreateUser(['bypass node access']);
35 $this->drupalLogin($web_user);
37 // Attempt to access edit page.
38 $this->drupalGet("node/" . $node->id() . "/edit");
39 $this->assertResponse(200);