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.
AssertEqual()
will be deprecated in Drupal 9 and removed in Drupal 10. It should be replaced by AssertEquals()
AssertLegacyTrait::assertEqual/8.6.x
BrowserTestBase::assertEquals/8.7.x
The deprecation was in Drupal 8.7 but on 19th Feb 2019 was put back to Drupal 9, and the deprecation warning removed from core 8.7
See #3031580: Undeprecate \Drupal\FunctionalTests\AssertLegacyTrait and \Drupal\KernelTests\AssertLegacyTrait in Drupal 8
Comment | File | Size | Author |
---|---|---|---|
#12 | 2867271-12.replace_assertequal.patch | 12.16 KB | jonathan1055 |
|
Comments
Comment #2
Pavan B S CreditAttribution: Pavan B S at Valuebound commentedApplying the patch, please review.
Comment #3
Pavan B S CreditAttribution: Pavan B S at Valuebound commentedComment #5
Pavan B S CreditAttribution: Pavan B S at Valuebound commentedApplying patch, please review.
Comment #6
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedHi Pavan B S,
Thank you for the patch. However, the link you give is to the AssertContent trait. Could you give a link to the coding standard you mention, and show exactly which methods/classes are now deprecated.
Jonathan
[edit: I've now fixed the links in the issue summary]
Comment #7
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThe original patch had several changes to assert functions but the patch in #4 just concentrates on replacing AssertEqual() with AssertEquals() so we will keep this issue to address that single task.
Old:
assertEqual($actual, $expected, $message = '')
New:
assertEquals($expected, $actual, $message = '', $delta = 0.0, $maxDepth = 10, $canonicalize = FALSE, $ignoreCase = FALSE)
Note that the first two parameters need to be swapped around.
Comment #8
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedComment #9
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedLinked to parent issue.
Note that this is not currently (at 8.7.x or 8.6.10) producing any deprecation warnings during testing.
Comment #10
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThe core issue #3031580: Undeprecate \Drupal\FunctionalTests\AssertLegacyTrait and \Drupal\KernelTests\AssertLegacyTrait in Drupal 8 removed the deprecation warnings from
FunctionalTests/AssertLegacyTrait.php
and/KernelTests/AssertLegacyTrait.php
so that is why we do not see them in test output.Looks like
AssertEqual()
is not going to be deprecated until Drupal 9 and won't be disappearing until Drupal 10.Comment #11
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedUpdated title and issue summary. We can still work on this now, though.
Comment #12
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedThe patch in #4 from April 2017 only changed three test files. API, Multilingual and Tokens.
assertEqual()
is used in five other tests: Admin, DefaultTime, Devel, PastDates and Revisioning. Some of these have been added since the the patch was created. Here's a patch for all eight tests affected.Note that with new syntax the expected value comes first, then the actual tested value. In the Revisioning test, we had a 4th parameter $group, which is not required (never was really)
Comment #14
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commentedCommitted.
Thanks Pavan B S for starting off this correction.
Comment #15
jonathan1055 CreditAttribution: jonathan1055 as a volunteer commented