You are here

private function FocalPointCollectorTest::addField in Acquia Content Hub 8.2

Add a field to the content type.

1 call to FocalPointCollectorTest::addField()
FocalPointCollectorTest::setUp in tests/src/Kernel/DependencyCollector/FocalPointCollectorTest.php

File

tests/src/Kernel/DependencyCollector/FocalPointCollectorTest.php, line 157

Class

FocalPointCollectorTest
Test focal point dependency collector.

Namespace

Drupal\Tests\acquia_contenthub\Kernel\DependencyCollector

Code

private function addField() {
  FieldStorageConfig::create([
    'entity_type' => self::ENTITY_TYPE,
    'field_name' => self::FIELD_NAME,
    'type' => self::FIELD_TYPE,
    'cardinality' => 1,
  ])
    ->save();
  FieldConfig::create([
    'entity_type' => self::ENTITY_TYPE,
    'field_name' => self::FIELD_NAME,
    'bundle' => self::BUNDLE,
    'label' => $this
      ->randomMachineName(),
  ])
    ->save();

  /** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $display_repository */
  $display_repository = \Drupal::service('entity_display.repository');
  $display_repository
    ->getFormDisplay('node', self::BUNDLE)
    ->setComponent(self::FIELD_NAME, [
    'type' => 'image_focal_point',
    'settings' => [],
  ])
    ->save();
}