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
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | interdiff_4-13.txt | 6.26 KB | sahil rohilla01 |
| #13 | 3221140-13.patch | 6.26 KB | sahil rohilla01 |
| #4 | 3221140-4.patch | 7.26 KB | guilhermevp |
Issue fork drupal-3221140
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
xjmUsing static vocabulary names would also be acceptable, unless the test is specifically testing conditions of variation in a name, in which case a data provider would be the solution. Probably the former. :)
Comment #3
guilhermevp commentedComment #4
guilhermevp commentedCreated a first patch for review, started by just removing
mb_strtolower(), but if statics are preferred I can make the changes.Please, review.
Comment #6
matroskeenIsn't the machine name have the following requirements? "only lowercase letters, numbers, and underscores"
See related issues: #3174874: MediaTypeCreationTrait creates media type with invalid machine-readable name and #2556711: Tired of Unicode::strtolower($this->randomMachineName()).
And here is an active task to teach
randomMachineNamegenerate a valid machine name: #2972573: randomMachineName() should conform to processMachineName() patternComment #7
guilhermevp commentedYes, that seems the case. Maybe I can use static machine names for that or use TaxonomyTestTrait::createVocabulary() if that change will happen at all.
Comment #8
phenaproximaI think, for now, it's okay to change to static names where possible.
Comment #9
guilhermevp commentedComment #13
sahil rohilla01 commentedReroll patch-4
Comment #14
ameymudras commentedGoing 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
Comment #17
quietone commentedThis was fixed in #3376281: Random machine names no longer need to be wrapped in strtolower()