Problem/Motivation
Tests for Drupal\Core\Template\Attribute are split between the Common and Template test namespaces. This makes related test coverage harder to locate.
Steps to reproduce
Review Drupal\Tests\Core\Common\AttributesTest and Drupal\Tests\Core\Template\AttributeTest. Both classes test Drupal\Core\Template\Attribute.
Proposed resolution
Move the tests and data provider from Drupal\Tests\Core\Common\AttributesTest into Drupal\Tests\Core\Template\AttributeTest. Remove the empty Common test class.
Remaining tasks
Review the merge request and confirm the consolidated test class passes.
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
Moved the AttributeTest class tests from Common to Template.
Issue fork drupal-2850635
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
joelpittetComment #15
smustgrave commentedThank you for creating this issue to improve Drupal.
We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.
Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.
Thanks!
Comment #17
smustgrave commentedProbably a good novice task for sure.
Comment #20
kieran.cottI've updated the issue summary and opened an MR that moves tests in Drupal\Tests\Core\Common\AttributesTest to Drupal\Tests\Core\Template\AttributeTest and removed the empty Common test class.
Comment #22
dcam commentedThis needs more work than to copy the functions of one test into the other. There is duplication of tests between the two.
testAttributeIteration()appears to have the exact same purpose astestIterate(). The difference is thattestIterate()tests more iterations, which would maketestAttributeIteration()superfluous and not worth copying.testDrupalAttributes()looks identical in purpose totestAttributeValues(). I didn't study them in-depth, but it looks like most of the test cases between the two functions are valid, with maybe one or two being duplicative. Instead of copyingtestDrupalAttributes(), I'd merge the cases fromproviderTestAttributeData()intoproviderTestAttributeValues().Comment #23
kieran.cottThanks, @dcam, I've updated
AttributeTest.phpto:- Remove redundant
testAttributeIteration().- Remove
testDrupalAttributes()and its provider.- Merge all distinct cases into
providerTestAttributeValues()as named datasets.Comment #24
dcam commentedMuch better. Thank you for doing that additional work.
Committers: The comments from the body of
providerTestAttributeData()were not copied toproviderTestAttributeValues(). I'm not sure that they're necessary, given that each test case has a key. But there's probably a little bit of context lost. Please check it when reviewing.Comment #25
mstrelan commentedHas anyone investigated why we have two similar tests in the first place? Looks to me like the one in
Core\Commonnamespace was in #2003568: Convert tags,attributes, diff and url validation unit tests to phpunit and theCore\Templateone was a few months later, in #2083941: \Drupal\Core\Theme\Attribute->value() is named wrong and does not work. Seems like it was not intentional, just missed that a test already exists.After this there are only 2 tests left in that
Core\Commonnamespace. I wonder if there is a better place for them? Not in scope for this issue.EDIT: opened #3618406: Move DiffArrayTest and TagsTest to Core\Utility namespace
Comment #26
dcam commentedI didn't check.
Comment #27
dcam commentedIf the tests were committed a few months apart, then it's entirely possible they were developed in parallel.
Comment #30
mstrelan commentedThis didn't cherry-pick cleanly since #3562361: Add type hints to core/tests code via Rector - round 2 was not backported to 11.x, but since it was only adding types to a now-deleted file I resolved it by deleting the same file in the cherry-pick commit.
Committed and pushed to main and 11.x, thanks!