protected function FieldResolverTest::makeField in Drupal 10
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Kernel/Context/FieldResolverTest.php \Drupal\Tests\jsonapi\Kernel\Context\FieldResolverTest::makeField()
- 9 core/modules/jsonapi/tests/src/Kernel/Context/FieldResolverTest.php \Drupal\Tests\jsonapi\Kernel\Context\FieldResolverTest::makeField()
Creates a field for a specified entity type/bundle.
Parameters
string $type: The field type.
string $name: The name of the field to create.
string $entity_type: The entity type to which the field will be attached.
string[] $bundles: The entity bundles to which the field will be attached.
array $storage_settings: Custom storage settings for the field.
array $config_settings: Custom configuration settings for the field.
1 call to FieldResolverTest::makeField()
- FieldResolverTest::setUp in core/modules/ jsonapi/ tests/ src/ Kernel/ Context/ FieldResolverTest.php 
File
- core/modules/ jsonapi/ tests/ src/ Kernel/ Context/ FieldResolverTest.php, line 372 
Class
- FieldResolverTest
- @coversDefaultClass \Drupal\jsonapi\Context\FieldResolver @group jsonapi
Namespace
Drupal\Tests\jsonapi\Kernel\ContextCode
protected function makeField($type, $name, $entity_type, array $bundles, array $storage_settings = [], array $config_settings = []) {
  $storage_config = [
    'field_name' => $name,
    'type' => $type,
    'entity_type' => $entity_type,
    'settings' => $storage_settings,
  ];
  FieldStorageConfig::create($storage_config)
    ->save();
  foreach ($bundles as $bundle) {
    FieldConfig::create([
      'field_name' => $name,
      'entity_type' => $entity_type,
      'bundle' => $bundle,
      'settings' => $config_settings,
    ])
      ->save();
  }
}