You are here

protected function ResourceTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/rest/tests/src/Functional/ResourceTest.php \Drupal\Tests\rest\Functional\ResourceTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/rest/tests/src/Functional/ResourceTest.php, line 43

Class

ResourceTest
Tests the structure of a REST resource.

Namespace

Drupal\Tests\rest\Functional

Code

protected function setUp() {
  parent::setUp();

  // Create an entity programmatic.
  $this->entity = EntityTest::create([
    'name' => $this
      ->randomMachineName(),
    'user_id' => 1,
    'field_test_text' => [
      0 => [
        'value' => $this
          ->randomString(),
        'format' => 'plain_text',
      ],
    ],
  ]);
  $this->entity
    ->save();
  Role::load(AccountInterface::ANONYMOUS_ROLE)
    ->grantPermission('view test entity')
    ->save();
}