PageViewTest.php in Drupal 9
File
core/modules/node/tests/src/Functional/PageViewTest.php
View source
<?php
namespace Drupal\Tests\node\Functional;
use Drupal\node\Entity\Node;
class PageViewTest extends NodeTestBase {
protected $defaultTheme = 'stark';
public function testPageView() {
$node = $this
->drupalCreateNode();
$this
->assertNotEmpty(Node::load($node
->id()), 'Node created.');
$this
->drupalGet("node/" . $node
->id() . "/edit");
$this
->assertSession()
->statusCodeEquals(403);
$web_user = $this
->drupalCreateUser([
'access content',
]);
$this
->drupalLogin($web_user);
$this
->drupalGet("node/" . $node
->id() . "/edit");
$this
->assertSession()
->statusCodeEquals(403);
$web_user = $this
->drupalCreateUser([
'bypass node access',
]);
$this
->drupalLogin($web_user);
$this
->drupalGet("node/" . $node
->id() . "/edit");
$this
->assertSession()
->statusCodeEquals(200);
}
}