You are here

protected function JsonApiAccessTest::setUp in Access unpublished 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/JsonApiAccessTest.php, line 44

Class

JsonApiAccessTest
Tests the article creation.

Namespace

Drupal\Tests\access_unpublished\Functional

Code

protected function setUp() {
  parent::setUp();
  NodeType::create([
    'type' => 'page',
    'name' => 'page',
  ])
    ->save();
  $this
    ->rebuildAll();
  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);
}