diff -u b/src/Entity/Form/GroupTypeForm.php b/src/Entity/Form/GroupTypeForm.php --- b/src/Entity/Form/GroupTypeForm.php +++ b/src/Entity/Form/GroupTypeForm.php @@ -125,12 +125,12 @@ } } - $form['title_label'] = array( + $form['title_label'] = [ '#title' => t('Title field label'), '#type' => 'textfield', '#default_value' => $fields['label']->getLabel(), '#required' => TRUE, - ); + ]; return $this->protectBundleIdElement($form); } @@ -183,7 +183,7 @@ // Update title field definition. $title_field = $fields['label']; $title_label = $form_state->getValue('title_label'); - if ($title_field->getLabel() != $title_label) { + if ($title_field->getLabel() !== $title_label) { $title_field->getConfig($type->id())->setLabel($title_label)->save(); } reverted: --- b/src/Tests/GroupTypeTest.php +++ /dev/null @@ -1,50 +0,0 @@ -drupalCreateUser(array( - 'bypass group access', - 'administer group' - )); - $this->drupalLogin($web_user); - - // Define group type fields. - $edit = array( - 'label' => 'Foo group', - 'id' => 'foo', - 'description' => 'Foo description', - 'title_label' => $group_type_title, - ); - - // Create a new group type. - $this->drupalPostForm('admin/group/types/add', $edit, t('Save group type')); - - /** @var EntityFieldManager $fieldManager */ - $fieldManager = \Drupal::service('entity_field.manager'); - $fields = $fieldManager->getFieldDefinitions('group', 'foo'); - - $this->assertEqual($fields['label']->getLabel(), $group_type_title, 'Group label field is set.'); - } -} only in patch2: unchanged: --- a/tests/src/Functional/GroupBrowserTestBase.php +++ b/tests/src/Functional/GroupBrowserTestBase.php @@ -22,6 +22,13 @@ abstract class GroupBrowserTestBase extends BrowserTestBase { protected $entityTypeManager; /** + * The entity type manager service. + * + * @var \Drupal\Core\Entity\EntityFieldManagerInterface + */ + protected $entityFieldManager; + + /** * A test user with group creation rights. * * @var \Drupal\user\UserInterface @@ -34,6 +41,7 @@ abstract class GroupBrowserTestBase extends BrowserTestBase { protected function setUp() { parent::setUp(); $this->entityTypeManager = $this->container->get('entity_type.manager'); + $this->entityFieldManager = $this->container->get('entity_field.manager'); $this->groupCreator = $this->drupalCreateUser($this->getGlobalPermissions()); $this->drupalLogin($this->groupCreator); } only in patch2: unchanged: --- /dev/null +++ b/tests/src/Functional/GroupTypeCreationTest.php @@ -0,0 +1,48 @@ +drupalGet('/admin/group/types/add'); + $this->assertSession()->statusCodeEquals(200); + + $submit_button = 'Save group type'; + $this->assertSession()->buttonExists($submit_button); + + $edit = [ + 'Name' => 'Foo group', + 'id' => 'foo', + 'Title field label' => $group_type_title, + ]; + $this->submitForm($edit, $submit_button); + + $fields = $this->entityFieldManager->getFieldDefinitions('group', 'foo'); + + $this->assertEquals($group_type_title, $fields['label']->getLabel()); + } + +}