You are here

protected function LinkFieldSerializerTest::setUp in Acquia Content Hub 8.2

Overrides EntityKernelTestBase::setUp

File

tests/src/Kernel/EventSubscriber/SerializeContentField/LinkFieldSerializerTest.php, line 56

Class

LinkFieldSerializerTest
Tests Link Field Serialization.

Namespace

Drupal\Tests\acquia_contenthub\Kernel\EventSubscriber\SerializeContentField

Code

protected function setUp() : void {
  if (version_compare(\Drupal::VERSION, '9.0', '>=')) {
    static::$modules[] = 'path_alias';
  }
  parent::setUp();
  if (version_compare(\Drupal::VERSION, '8.8.0', '>=')) {
    $this
      ->installEntitySchema('path_alias');
  }
  $this
    ->installEntitySchema('node_type');
  $this
    ->installConfig([
    'node',
    'filter',
  ]);
  $this
    ->installEntitySchema('field_config');
  $this
    ->installSchema('node', 'node_access');
  $this
    ->installSchema('user', 'users_data');
  $this
    ->createContentType([
    'type' => 'page',
    'name' => 'Page',
  ])
    ->save();
  $field_storage = FieldStorageConfig::create([
    'field_name' => 'link',
    'entity_type' => 'node',
    'type' => 'link',
    'cardinality' => -1,
  ]);
  $field_storage
    ->save();
  $field = FieldConfig::create([
    'field_storage' => $field_storage,
    'bundle' => 'page',
    'label' => 'link',
    'settings' => [
      'link_type' => LinkItemInterface::LINK_GENERIC,
    ],
  ]);
  $field
    ->save();
  $field2_storage = FieldStorageConfig::create([
    'field_name' => 'link2',
    'entity_type' => 'node',
    'type' => 'link',
    'cardinality' => -1,
  ]);
  $field2_storage
    ->save();
  $field2 = FieldConfig::create([
    'field_storage' => $field2_storage,
    'bundle' => 'page',
    'label' => 'link',
    'settings' => [
      'link_type' => LinkItemInterface::LINK_GENERIC,
    ],
  ]);
  $field2
    ->save();
  $this->serializer = new LinkFieldSerializer();
}