Don't call mb_strtolower() when generating machine names in Taxonomy tests

Created on 28 June 2021, over 3 years ago
Updated 23 January 2023, almost 2 years ago

Problem/Motivation

Taxonomy's test suite is littered with this sort of thing when creating vocabularies:

$vid = mb_strtolower($this->randomMachineName());

This isn't necessary. The calls to mb_strtolower() aren't really needed, because even though $this->randomMachineName() can return upper-case letters, those are allowed in machine names.

Steps to reproduce

N/A

Proposed resolution

When creating vocabularies in tests, don't call mb_strtolower($this->randomMachineName()) to generate vocabulary IDs. Either rely directly on $this->randomMachineName(), or use TaxonomyTestTrait::createVocabulary().

Remaining tasks

Implement the proposed resolution across Taxonomy's test suite, then commit the changes. No additional test coverage should be necessary.

User interface changes

None.

API changes

None.

Data model changes

None.

Release notes snippet

📌 Task
Status

Needs work

Version

10.1

Component
Taxonomy 

Last updated 5 days ago

  • Maintained by
  • 🇺🇸United States @xjm
  • 🇬🇧United Kingdom @catch
Created by

🇺🇸United States phenaproxima Massachusetts

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇮🇳India ameymudras

    Going by the problem statement upper case letters are allowed in machine names but there is a constraint which exists that doesn't allow this

    core/modules/field/src/Entity/FieldStorageConfig.php

     if (!preg_match('/^[_a-z]+[_a-z0-9]*$/', $values['field_name'])) {
          throw new FieldException("Attempt to create a field storage {$values['field_name']} with invalid characters. Only lowercase alphanumeric characters and underscores are allowed, and only lowercase letters and underscore are allowed as the first character");
        }
    
Production build 0.71.5 2024