protected function FieldGroupTestTrait::createGroup in Field Group 8
Same name and namespace in other branches
- 8.3 tests/src/Functional/FieldGroupTestTrait.php \Drupal\Tests\field_group\Functional\FieldGroupTestTrait::createGroup()
Create a new group.
Parameters
string $entity_type: The entity type as string.
string $bundle: The bundle of the enity type
string $context: The context for the group.
string $mode: The view/form mode.
array $data: Data for the field group.
Return value
\stdClass An object that represents the field group.
7 calls to FieldGroupTestTrait::createGroup()
- EntityDisplayTest::testAccordion in tests/
src/ Functional/ EntityDisplayTest.php - Test the accordion formatter.
- EntityDisplayTest::testFieldAccess in tests/
src/ Functional/ EntityDisplayTest.php - Test field access for field groups.
- EntityDisplayTest::testFieldset in tests/
src/ Functional/ EntityDisplayTest.php - Test the fieldset formatter.
- EntityDisplayTest::testHtmlElement in tests/
src/ Functional/ EntityDisplayTest.php - Test the html element formatter.
- EntityDisplayTest::testTabs in tests/
src/ Functional/ EntityDisplayTest.php - Test the tabs formatter.
File
- tests/
src/ Functional/ FieldGroupTestTrait.php, line 29
Class
- FieldGroupTestTrait
- Provides common functionality for the FieldGroup test classes.
Namespace
Drupal\Tests\field_group\FunctionalCode
protected function createGroup($entity_type, $bundle, $context, $mode, array $data) {
if (!isset($data['format_settings'])) {
$data['format_settings'] = array();
}
$data['format_settings'] += _field_group_get_default_formatter_settings($data['format_type'], $context);
$group_name = 'group_' . Unicode::strtolower($this
->randomMachineName());
$field_group = (object) array(
'group_name' => $group_name,
'entity_type' => $entity_type,
'bundle' => $bundle,
'mode' => $mode,
'context' => $context,
'children' => isset($data['children']) ? $data['children'] : array(),
'parent_name' => isset($data['parent']) ? $data['parent'] : '',
'weight' => isset($data['weight']) ? $data['weight'] : 0,
'label' => isset($data['label']) ? $data['label'] : $this
->randomString(8),
'format_type' => $data['format_type'],
'format_settings' => $data['format_settings'],
'region' => 'content',
);
field_group_group_save($field_group);
return $field_group;
}