protected function FeedsCommonTrait::createFieldWithStorage in Feeds 8.3
Creates a field and an associated field storage.
Parameters
string $field_name: The name of the field.
array $config: (optional) The field storage and instance configuration:
- entity_type: (optional) the field's entity type. Defaults to 'node'.
- bundle: (optional) the field's bundle. Defaults to 'article'.
- type: (optional) the field's type. Defaults to 'text'.
- label: (optional) the field's label. Defaults to the field's name + the string ' label'.
- storage: (optional) additional keys for the field's storage.
- field: (optional) additional keys for the field.
24 calls to FeedsCommonTrait::createFieldWithStorage()
- BasicFieldSourceTest::testImportWithTaxonomyTermReferenceSource in tests/src/ Kernel/ Feeds/ Source/ BasicFieldSourceTest.php 
- Tests importing using a taxonomy term reference source.
- BasicFieldSourceTest::testImportWithTextfieldSource in tests/src/ Kernel/ Feeds/ Source/ BasicFieldSourceTest.php 
- Tests importing using a text field source.
- CsvParserTest::testAlterCsvSource in tests/src/ Kernel/ Feeds/ Parser/ CsvParserTest.php 
- Tests if data from a CSV file can be altered with an event subscriber.
- CsvParserTest::testImportCsvWithNonMachineNameColumnNames in tests/src/ Kernel/ Feeds/ Parser/ CsvParserTest.php 
- Tests importing a CSV file with non machine name column names.
- CsvParserTest::testMapCustomSource in tests/src/ FunctionalJavascript/ Feeds/ Parser/ CsvParserTest.php 
- Tests adding a custom mapping source.
File
- tests/src/ Traits/ FeedsCommonTrait.php, line 82 
Class
- FeedsCommonTrait
- Provides methods useful for Kernel and Functional Feeds tests.
Namespace
Drupal\Tests\feeds\TraitsCode
protected function createFieldWithStorage($field_name, array $config = []) {
  $config += [
    'entity_type' => 'node',
    'bundle' => 'article',
    'type' => 'text',
    'label' => $field_name . ' label',
    'storage' => [],
    'field' => [],
  ];
  FieldStorageConfig::create($config['storage'] + [
    'field_name' => $field_name,
    'entity_type' => $config['entity_type'],
    'type' => $config['type'],
    'settings' => [],
  ])
    ->save();
  FieldConfig::create($config['field'] + [
    'entity_type' => $config['entity_type'],
    'bundle' => $config['bundle'],
    'field_name' => $field_name,
    'label' => $config['label'],
  ])
    ->save();
}