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