function ExternalNormalizersTest::setUp

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/ExternalNormalizersTest.php \Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest::setUp()
  2. 10 core/modules/jsonapi/tests/src/Functional/ExternalNormalizersTest.php \Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest::setUp()
  3. 11.x core/modules/jsonapi/tests/src/Functional/ExternalNormalizersTest.php \Drupal\Tests\jsonapi\Functional\ExternalNormalizersTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/jsonapi/tests/src/Functional/ExternalNormalizersTest.php, line 62

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();
}

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