protected function FieldResolverTest::makeField in JSON:API 8
Same name and namespace in other branches
- 8.2 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 tests/
src/ Kernel/ Context/ FieldResolverTest.php
File
- tests/
src/ Kernel/ Context/ FieldResolverTest.php, line 316
Class
- FieldResolverTest
- @coversDefaultClass \Drupal\jsonapi\Context\FieldResolver @group jsonapi @group legacy
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();
}
}