Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
While using parentheses does not break code coverage, the documentation shows no usage of them. Our code base is split right now, but we should follow the docs.
Proposed resolution
Remove parentheses from some @covers statements.
Some others will be fixed in other related issues.
Remaining tasks
Task | Novice task? | Contributor instructions | Complete? |
---|---|---|---|
Review patch to ensure that it fixes the issue, stays within scope, is properly documented, and follows coding standards | Instructions | ||
Update summary according to allowed changes in beta | Instructions |
User interface changes
No.
API changes
No.
Beta phase evaluation
Unfrozen changes | Unfrozen because it only changes automated tests for coding standards. |
---|
Comment | File | Size | Author |
---|---|---|---|
#28 | 2328919_28.patch | 90.17 KB | Mile23 |
#23 | phpunit-2328919-23.patch | 90.19 KB | Mile23 |
#23 | interdiff_20.txt | 7.91 KB | Mile23 |
#20 | phpunit-2328919-18.patch | 82.92 KB | YesCT |
#20 | interdiff.2328919.17.18.txt | 4.41 KB | YesCT |
Comments
Comment #1
tim.plunkettComment #2
dawehnerk
Comment #3
dawehnerPlease ensure that this is covered in the phpunit standard issue!
Comment #4
tstoecklerSorry, but I think because we require parens with @see it would be more consistent to require them here as well. Let's at least get some more input on this.
Comment #5
jhodgdonCoding standards changes are now part of the TWG
Comment #6
tim.plunkettNope. PHPUnit defines its coding standard, not us.
Comment #8
tim.plunkettRerolled.
Comment #9
tstoecklerNope. #6 is incorrect (we also don't follow symphony cs) and also no reference has been linked here.
Comment #10
tim.plunkettLink is in the IS. We don't use Symfony's CS because it conflicts with ours. We have no standard for @covers, therefore we should follow PHPUnit.
You may think its a good idea to deviate from that for no particular reason, but I disagree.
Comment #11
tstoecklerOK, so the link in the IS is not really a coding standard per sé, but sure, if all the examples follow a certain pattern that can be considered a standard. You're right that if there is no reason not to, then following the standard is a good thing. I still think that consistency with @see would be one reason not to, but surely weighing the two is a matter of personal opinion.
That said, and in case I didn't make that clear above, I have absolutely no problem with this patch going in as is, I just don't see any reason to rush this at all and I don't think there is something that can be called a consensus here.
So how about we just leave this at "needs review" and see what some other folks think about this?
Comment #12
Mile23I would RTBC this if it applied.
It would require heroic effort to re-roll, given the number of piecemeal @covers changes.
PHPUnit conventions are plenty fine for Drupal.
Comment #13
Mile23Here's a re-roll.
There are still scads of () out there, which you can find with this regex:
@covers ::\w+\(
I'll poke at them over the next few days.
Comment #15
Mile23Removed ExternalUrlTest.php since it was removed in #2343759: Provide an API function to replace url()/l() for external urls.
Previous patch adds out-of-scope stuff to settings and services files, possibly due to poor re-roll. Fixed.
Previos patch adds testFieldSqlSchemaForEntityWithStringIdentifier() back, definitely due to poor re-roll. :-) Fixed.
I think I'll leave this patch for whoever wants to RTBC. Other () fixes will be in related patches.
Comment #16
YesCT CreditAttribution: YesCT commentednote there are some fixes (not just paren removal)
So reviewers may find applying the patch and using git diff --color-words helpful in spotting those.
---
@Mile23
Please link those issues, so we know where other () removals will be done.
---
Also, since this is a normal task, we should update the summary with an "Allowed in beta?" section,
with info from https://www.drupal.org/core/beta-changes
Comment #17
YesCT CreditAttribution: YesCT commentedwhy are we adding getSchema here?
A separate issue for that seems reasonable.
Similar for addFieldSchema
we should fix these here... if there is not a separate issue fixing the @cover -> @covers (or even if there is... it should be easy to reroll for this)
I dont think we should fix the one line summary coding standards thing in this issue. Especially, since we may not do that for phpunit tests.
setDirection is no longer a method.
Comment #18
YesCT CreditAttribution: YesCT commentedtaking out the
- * @covers ::getControllerClass
+ * @covers ::getController
change.
I think that makes these changes only in scope now.
Comment #19
Mile23Adding beta phase evaluation stuff.
Comment #20
YesCT CreditAttribution: YesCT commentedoops. files...
Comment #21
YesCT CreditAttribution: YesCT commentedregarding #17 1.
#2358657: Wrong @covers definitions in Drupal project took out the getSchema and addFieldSchema, so we should not add them back in. I think it was just an artifact of the reroll.
Comment #22
YesCT CreditAttribution: YesCT commentedand #2300131: EntityResolverManager instantiates objects unnecessarily renamed getController to getControllerClass, so let's leave it getControllerClass in the covers also. ;)
So I dont think we need any separate issues.
Comment #23
Mile23Yes, there were far fewer than I thought. I guess I should have done the search on the *patched* version eh?
Anyway, here's the new hotness, removing all the other parentheses I could find, which passes
./vendor/bin/phpunit --strict --coverage-html
. This strict coverage mode complains about erroneous@covers
, so I think we're good.Updated #2057905: [policy, no patch] Discuss the standards for phpunit based tests with info about not using parentheses.
Comment #24
YesCT CreditAttribution: YesCT commentedreviewed that. looks super good to me, but I think I did too much to rtbc it.
Comment #25
jhodgdonI went through this patch carefully with color-words and have verified that the only changes are @cover -> @covers and removing () at the end of those lines. This is good to go. Soon so it does not need reroll.
Comment #26
geerlingguy CreditAttribution: geerlingguy commentedTested with
--strict --coverage-text
, and it works great (1 fail, but that's due to #2373549: PHPUnit test testGetDoesntHitConsistentBackend failing when run with coverage reporting, which has an RTBC patch :). I like following PHPUnit's conventions here, and agree with IS.Comment #27
alexpottComment #28
Mile23Rebase of #23.
Comment #29
jibranBack to RTBC.
Comment #30
alexpottThis issue is a unfrozen change (documenation and tests) as per https://www.drupal.org/core/beta-changes. Committed 1a73d7e and pushed to 8.0.x. Thanks!