annotate core/modules/node/tests/src/Functional/PageViewTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
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@17 13
Chris@0 14 /**
Chris@0 15 * Tests an anonymous and unpermissioned user attempting to edit the node.
Chris@0 16 */
Chris@0 17 public function testPageView() {
Chris@0 18 // Create a node to view.
Chris@0 19 $node = $this->drupalCreateNode();
Chris@0 20 $this->assertTrue(Node::load($node->id()), 'Node created.');
Chris@0 21
Chris@0 22 // Try to edit with anonymous user.
Chris@0 23 $this->drupalGet("node/" . $node->id() . "/edit");
Chris@0 24 $this->assertResponse(403);
Chris@0 25
Chris@0 26 // Create a user without permission to edit node.
Chris@0 27 $web_user = $this->drupalCreateUser(['access content']);
Chris@0 28 $this->drupalLogin($web_user);
Chris@0 29
Chris@0 30 // Attempt to access edit page.
Chris@0 31 $this->drupalGet("node/" . $node->id() . "/edit");
Chris@0 32 $this->assertResponse(403);
Chris@0 33
Chris@0 34 // Create user with permission to edit node.
Chris@0 35 $web_user = $this->drupalCreateUser(['bypass node access']);
Chris@0 36 $this->drupalLogin($web_user);
Chris@0 37
Chris@0 38 // Attempt to access edit page.
Chris@0 39 $this->drupalGet("node/" . $node->id() . "/edit");
Chris@0 40 $this->assertResponse(200);
Chris@0 41 }
Chris@0 42
Chris@0 43 }