protected function GraphQLContentTestBase::addField in GraphQL 8.3
Add a field to test content type.
Parameters
string $type: Field type.
string $fieldName: Field machine name.
string $label: Label for the field.
5 calls to GraphQLContentTestBase::addField()
- EntityFieldValueTest::testBoolean in modules/
graphql_core/ tests/ src/ Kernel/ Entity/ EntityFieldValueTest.php - Test boolean fields.
- EntityFieldValueTest::testFieldAssignment in modules/
graphql_core/ tests/ src/ Kernel/ Entity/ EntityFieldValueTest.php - Verify that fields are assigned correctly among bundles.
- EntityFieldValueTest::testRawValues in modules/
graphql_core/ tests/ src/ Kernel/ Entity/ EntityFieldValueTest.php - Test if the basic fields are available on the interface.
- EntityFieldValueTest::testText in modules/
graphql_core/ tests/ src/ Kernel/ Entity/ EntityFieldValueTest.php - Test a simple text field.
- ImageFieldTest::setUp in modules/
graphql_core/ tests/ src/ Kernel/ Images/ ImageFieldTest.php
File
- modules/
graphql_core/ tests/ src/ Kernel/ GraphQLContentTestBase.php, line 101
Class
- GraphQLContentTestBase
- Base class for node based tests.
Namespace
Drupal\Tests\graphql_core\KernelCode
protected function addField($type, $fieldName, $multi = TRUE, $label = 'Label', $bundle = 'test') {
FieldStorageConfig::create([
'field_name' => $fieldName,
'entity_type' => 'node',
'type' => $type,
'cardinality' => $multi ? -1 : 1,
])
->save();
FieldConfig::create([
'entity_type' => 'node',
'bundle' => $bundle,
'field_name' => $fieldName,
'label' => $label,
])
->save();
}