You are here

public function ExternalNormalizersTest::setUp in JSON:API 8.2

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

Overrides BrowserTestBase::setUp

File

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

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 and create the test entities.
  Role::load(RoleInterface::ANONYMOUS_ID)
    ->grantPermission('view test entity')
    ->grantPermission('create entity_test entity_test_with_bundle entities')
    ->save();
  $this
    ->config('jsonapi.settings')
    ->set('read_only', FALSE)
    ->save(TRUE);
  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();
}