Mercurial > hg > isophonics-drupal-site
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/node/tests/src/Functional/PageViewTest.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,42 @@ +<?php + +namespace Drupal\Tests\node\Functional; + +use Drupal\node\Entity\Node; + +/** + * Create a node and test edit permissions. + * + * @group node + */ +class PageViewTest extends NodeTestBase { + /** + * Tests an anonymous and unpermissioned user attempting to edit the node. + */ + public function testPageView() { + // Create a node to view. + $node = $this->drupalCreateNode(); + $this->assertTrue(Node::load($node->id()), 'Node created.'); + + // Try to edit with anonymous user. + $this->drupalGet("node/" . $node->id() . "/edit"); + $this->assertResponse(403); + + // Create a user without permission to edit node. + $web_user = $this->drupalCreateUser(['access content']); + $this->drupalLogin($web_user); + + // Attempt to access edit page. + $this->drupalGet("node/" . $node->id() . "/edit"); + $this->assertResponse(403); + + // Create user with permission to edit node. + $web_user = $this->drupalCreateUser(['bypass node access']); + $this->drupalLogin($web_user); + + // Attempt to access edit page. + $this->drupalGet("node/" . $node->id() . "/edit"); + $this->assertResponse(200); + } + +}