Skip to content
Snippets Groups Projects

Issue #3341682: New config schema data type: `required_label`

Closed Wim Leers requested to merge issue/drupal-3341682:3341682-label-type-validation into 11.x

Merge request reports

Closed by Lauri TimmaneeLauri Timmanee 1 year ago (Aug 17, 2023 9:29am UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Adam G-H
  • 168 171
    172 /**
    173 * Tests validation of config entity's label.
    174 *
    175 * @see \Drupal\Core\Entity\EntityInterface::label()
    176 * @see \Drupal\Core\Entity\EntityBase::label()
    177 */
    178 public function testLabelValidation(): void {
    179 // Some entity types are labelless:
    180 // - \Drupal\Core\Entity\Entity\EntityFormDisplay
    181 // - \Drupal\Core\Entity\Entity\EntityViewDisplay
    182 // - \Drupal\language\Entity\ContentLanguageSettings
    183 // - \Drupal\rest\Entity\RestResourceConfig
    184 if ($this->entity->label() === NULL) {
    185 $this->markTestSkipped();
    186 }
  • Adam G-H
  • Adam G-H
  • 186 }
    187 // @todo Remove this in https://www.drupal.org/i/3231354.
    188 if ($this->entity->getEntityType()->id() === 'editor') {
    189 $this->markTestSkipped();
    190 }
    191 // @todo Remove this in https://www.drupal.org/i/2939931.
    192 if ($this->entity instanceof LayoutBuilderEntityViewDisplay) {
    193 $this->markTestSkipped();
    194 }
    195 if ($this->entity->getEntityType()->getKey('label') === $this->entity->getEntityType()->getKey('id')) {
    196 $this->markTestSkipped('This entity type uses the ID as the label; a labelless entity is hence impossible.');
    197 }
    198 $label_property = $this->entity->getEntityType()->getKey('label');
    199 if ($label_property === FALSE && !method_exists($this, 'removeLabel')) {
    200 throw new \LogicException(sprintf('Please implement a removeLabel() method to allow testing a labelless %s.', (string) $this->entity->getEntityType()->getSingularLabel()));
    201 }
    • Comment on lines +199 to +201

      I don't understand this. If there's not a label key, we want to test the removal of labels...??

    • Author Developer

      Yes. See the one test that uses this: Block. That config entity type stores its label not as a top-level property, but as a second level property, which is why it is impossible to define that as an entity key.

      :shrug:

    • Author Developer

      This was simplified months ago. :nerd:

    • Adam G-H changed this line in version 41 of the diff

      changed this line in version 41 of the diff

    • Please register or sign in to reply
  • Adam G-H
  • Adam G-H
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading