You are here

protected function AccessTest::setUp in Access unpublished 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/AccessTest.php, line 40

Class

AccessTest
Tests the article creation.

Namespace

Drupal\Tests\access_unpublished\Functional

Code

protected function setUp() {
  parent::setUp();
  NodeType::create([
    'type' => 'page',
    'name' => 'page',
  ])
    ->save();
  user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
    'access content',
    'access_unpublished node page',
  ]);

  // Create an unpublished entity.
  $this->entity = $this
    ->createNode([
    'status' => FALSE,
  ]);
  $assert_session = $this
    ->assertSession();

  // Verify that the entity is not accessible.
  $this
    ->drupalGet($this->entity
    ->toUrl());
  $assert_session
    ->statusCodeEquals(403);
}