annotate core/modules/node/tests/src/Functional/PageViewTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Tests\node\Functional;
Chris@0 4
Chris@0 5 use Drupal\node\Entity\Node;
Chris@0 6
Chris@0 7 /**
Chris@0 8 * Create a node and test edit permissions.
Chris@0 9 *
Chris@0 10 * @group node
Chris@0 11 */
Chris@0 12 class PageViewTest extends NodeTestBase {
Chris@0 13 /**
Chris@0 14 * Tests an anonymous and unpermissioned user attempting to edit the node.
Chris@0 15 */
Chris@0 16 public function testPageView() {
Chris@0 17 // Create a node to view.
Chris@0 18 $node = $this->drupalCreateNode();
Chris@0 19 $this->assertTrue(Node::load($node->id()), 'Node created.');
Chris@0 20
Chris@0 21 // Try to edit with anonymous user.
Chris@0 22 $this->drupalGet("node/" . $node->id() . "/edit");
Chris@0 23 $this->assertResponse(403);
Chris@0 24
Chris@0 25 // Create a user without permission to edit node.
Chris@0 26 $web_user = $this->drupalCreateUser(['access content']);
Chris@0 27 $this->drupalLogin($web_user);
Chris@0 28
Chris@0 29 // Attempt to access edit page.
Chris@0 30 $this->drupalGet("node/" . $node->id() . "/edit");
Chris@0 31 $this->assertResponse(403);
Chris@0 32
Chris@0 33 // Create user with permission to edit node.
Chris@0 34 $web_user = $this->drupalCreateUser(['bypass node access']);
Chris@0 35 $this->drupalLogin($web_user);
Chris@0 36
Chris@0 37 // Attempt to access edit page.
Chris@0 38 $this->drupalGet("node/" . $node->id() . "/edit");
Chris@0 39 $this->assertResponse(200);
Chris@0 40 }
Chris@0 41
Chris@0 42 }