Closed (fixed)
Project:
Drupal core
Version:
8.8.x-dev
Component:
phpunit
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Sep 2017 at 21:23 UTC
Updated:
6 Nov 2019 at 11:32 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
karthikkumarbodu commentedComment #3
karthikkumarbodu commentedComment #4
karthikkumarbodu commentedComment #6
cilefen commentedHi. I see we have about 14 almost identical issues. I’m not sure we need so many issues. Refer to https://www.drupal.org/core/scope for guidance.
Comment #7
aks22 commentedAgree with @cilefen.
Comment #8
karthikkumarbodu commented@cilefen can you please suggest me on the next steps to squash the issues.
Comment #9
cilefen commentedClose all but this one as duplicates and change this one so that it fixes all usages.
Comment #10
karthikkumarbodu commentedAdded new patch and inter diff file replacing all instances of assertEqual to assertEquals
Comment #12
cilefen commentedComment #13
ivan berezhnov commentedComment #14
andypostReroll + remove change from
AssertLegacyTraitComment #16
piggito commentedAdding reroll for patch in #14 + more replaces for instances of assertEqual
Comment #18
piggito commentedI'm reverting the change for simpletest-based tests cause they don't have the assertEquals function.
Also, we used to pass $group as 4th parameter to asserEqual https://api.drupal.org/api/drupal/core%21modules%21simpletest%21src%21Te...
however when using assertEquals this 4th parameter has now a different purpose
https://api.drupal.org/api/drupal/vendor%21phpunit%21phpunit%21src%21Fra...
https://phpunit.de/manual/current/en/appendixes.assertions.html#appendix...
Then, I'm removing the 4th parameter when used since we don't have an equivalent for the old $group parameter.
Comment #20
piggito commentedLooks like core/modules/node/tests/src/Traits/ContentTypeCreationTrait.php is also used in simpletest so reverting the change here too.
Comment #21
andypostPatch looks great, but how we can make sure that all places covered?
Guess it needs to trigger_error or a kind of that
Comment #23
borisson_Like @andypost said in #21, we need to add deprecation. This can go in
\Drupal\KernelTests\AssertLegacyTrait::assertEqual. We should probably have issues for all protected methods in that trait.The deprecation policy is pretty clear about how we should do that.
Comment #24
gawaksh commentedThis would solve the purpose.
Comment #26
borisson_That patch doesn't seem correct, it's also ~3MB bigger than the previous patch.
Comment #27
gawaksh commented@borrison My bad, I'll upload a fresh one. Sorry for the inconvenience.
Comment #28
gawaksh commentedComment #30
karimei commentedI'm looking into this issue.
Comment #31
mmbkComment #32
karimei commentedI had difficulties rerolling the patch will try it again.
Comment #33
tatarbjThe only thing that should happen here is to replace assertEqual to assertEquals in config module: /core/modules/config.
The current patch and the ones before fail because of replacing them everywhere that is not the scope of this issue.
Comment #34
tatarbjInstead of rerolling it, just get 8.7.x and do the replacement in the mentioned folder.
Comment #35
karimei commentedThanks for the hint.
I produced a patch according to the suggestion in #33
Comment #36
mmbk@karimei this looks good for me, thanks you for your work, and please excuse the confusion at the sprint ;-)
EDIT:
#35 is a complete new patch for 8.7.x not based on the previous patches, so no interdiff is supplied.
Comment #38
tatarbjJust updating the title to reflect correctly to the scope of the issue.
The filename looks questionable btw as this issue was about compatibility against deprecated calls and not a coding standard issue, so if someone reviews it further don't get it wrong :)
Also core committers, that's the last one of its parent and follows the other child issues' solutions.
Nice job @karimei and @mmbk!
It seems definitely an RTBC for me too.
Comment #39
lendudeShouldn't this just use assertCount now?
Also,
assertEqualhad no 'expected' value vs 'actual' value in its two parameters (which is why there is no consistency for this across tests currently),assertEqualsdoes specify that the first parameter needs to be the expected value. This is not the case for a number of assertions here. The output for failed assertions becomes really confusing if you don't follow this standard.Comment #40
mmbk@lendude, you are totally right, we did not see that the paramaters are swapped.
From core/tests/Drupal/KernelTests/AssertLegacyTrait.php Line 50ff
So this needs some more work
As for changing the tests to assertCount, I think this is noch the scope of this ticket.
Comment #41
mmbkComment #42
lendudeAs an aside, I'm not 100% convinced we should be doing this until #2735005: Convert all Simpletest web tests to BrowserTestBase (or UnitTestBase/KernelTestBase) is done, so until http://simpletest-countdown.org/ hits zero. Because we might just introduce new instances of
assertEqual, or we will make the conversion of the last remaining tests even harder then they already are.Comment #44
vacho commentedComment #45
vacho commentedPatch rerolled
Comment #46
naveenvalechaThis should be N/R
Comment #47
smagdits commentedRerolled the previous patch and replaced 4 additional instances of assertEqual with assertEquals within ConfigEntityTest.php and ConfigInstallProfileOverrideTest.php. These changes are supplied in the interdiff.txt.
Comment #49
smagdits commentedI'm not sure #45 was rerolled correctly, it seems to include the deprecated Drupal::entityManager() within ConfigInstallProfileOverrideTest, which was included in 8.7 but not 8.8. Therefore #46 contains this as well. This test passes on a fresh 8.8 install, where it uses the correct entityTypeManager(). I'll be looking into this some more.
Comment #50
smagdits commentedRerolled #35 to bring it up to 8.8.x. No additional occurrences of assertEqual were found after rerolling. Uses entityTypeManager() as per 8.8.
Comment #51
yogeshmpawarSetting back to Needs Review & Triggering bots.
Comment #52
init90I've added corrections according to comment #39:
- Changed parameters order in
assertEquals()- Used
assertEqual()for suitable places.Comment #53
Andrew.Dmytriv commentedLooks good!
Comment #54
catchThese two examples both look like they need the parameters swapped.
Also here.
And here.
Comment #55
shubham.prakash commentedThis patch should fix the issue.
Comment #56
init90@catch, thanks for the review, you are right.
@shubham.prakash, thanks, changes look good.
I'm attaching changes between your patch and patch from #52.
In the future please provide interdiff by yourself, it makes patch review simpler.
How to create interdiff: https://www.drupal.org/documentation/git/interdiff
Changes were obvious so I'm returning status to RTBC.
Comment #58
catchCommitted 0ea7cee and pushed to 8.8.x. Thanks!
Comment #59
tatarbj