You are here

protected function FieldItemNormalizerTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 9 core/modules/jsonapi/tests/src/Kernel/Normalizer/FieldItemNormalizerTest.php \Drupal\Tests\jsonapi\Kernel\Normalizer\FieldItemNormalizerTest::setUp()

Overrides KernelTestBase::setUp

File

core/modules/jsonapi/tests/src/Kernel/Normalizer/FieldItemNormalizerTest.php, line 41

Class

FieldItemNormalizerTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\FieldItemNormalizer @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\Normalizer

Code

protected function setUp() : void {
  parent::setUp();
  $etm = $this->container
    ->get('entity_type.manager');
  $this->normalizer = new FieldItemNormalizer($etm);
  $this->normalizer
    ->setSerializer($this->container
    ->get('jsonapi.serializer'));
  $definitions = [];
  $definitions['links'] = BaseFieldDefinition::create('link')
    ->setLabel('Links');
  $definitions['internal_property_value'] = BaseFieldDefinition::create('single_internal_property_test')
    ->setLabel('Internal property');
  $definitions['no_main_property_value'] = BaseFieldDefinition::create('map')
    ->setLabel('No main property');
  $this->container
    ->get('state')
    ->set('entity_test.additional_base_field_definitions', $definitions);
  $etm
    ->clearCachedDefinitions();
}