You are here

public function ExternalNormalizersTest::setUp in JSON:API 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/ExternalNormalizersTest.php \Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/Functional/ExternalNormalizersTest.php, line 56

Class

ExternalNormalizersTest
Asserts external normalizers are handled as expected by the JSON API module.

Namespace

Drupal\Tests\jsonapi\Functional

Code

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

  // This test is not about access control at all, so allow anonymous users to
  // view the test entities.
  Role::load(RoleInterface::ANONYMOUS_ID)
    ->grantPermission('view test entity')
    ->save();
  FieldStorageConfig::create([
    'field_name' => 'field_test',
    'type' => 'string',
    'entity_type' => 'entity_test',
  ])
    ->save();
  FieldConfig::create([
    'field_name' => 'field_test',
    'entity_type' => 'entity_test',
    'bundle' => 'entity_test',
  ])
    ->save();
  $this->entity = EntityTest::create([
    'name' => 'Llama',
    'type' => 'entity_test',
    'field_test' => static::VALUE_ORIGINAL,
  ]);
  $this->entity
    ->save();
}