function ResourceTest::setUp

Same name in other branches
  1. 9 core/modules/rest/tests/src/Functional/ResourceTest.php \Drupal\Tests\rest\Functional\ResourceTest::setUp()
  2. 8.9.x core/modules/rest/tests/src/Functional/ResourceTest.php \Drupal\Tests\rest\Functional\ResourceTest::setUp()
  3. 11.x 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 44

Class

ResourceTest
Tests the structure of a REST resource.

Namespace

Drupal\Tests\rest\Functional

Code

protected function setUp() : void {
    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();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.