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
As title
Proposed resolution
Remove redundant assertion messages at the same time.
Example:
- $this->assertTrue(is_object($node), 'Node is an object');
+ $this->assertIsObject($node);
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#27 | raw-interdiff-21-27.txt | 1.68 KB | jungle |
#27 | 3131818-27.patch | 9.66 KB | jungle |
Comments
Comment #2
jungleComment #3
jungleUpdating IS and mentioning to remove assertion messages
Comment #4
jungleComment #5
jungleComment #6
mero.S CreditAttribution: mero.S as a volunteer and at AnyforSoft for AnyforSoft commentedPlease review patch.
Comment #7
jungle@mero.S, I did assign to myself. 🤦 If you want to work on one issue, better to assign yourself first. I will still submit mine, interdiff and comments coming next.
Comment #8
jungleComment #9
jungleWrong interdiff submitted in #8, sorry.
Comment #10
mero.S CreditAttribution: mero.S as a volunteer and at AnyforSoft for AnyforSoft commentedOkay, I'm sorry)
Comment #11
jungle@mero.S, no worries, anyway, thanks for working on this!
Review of #6
Instead of replacing it, I did remove the assertion in
if
which makes more sense to me.Note for reviewer(s): the assertion message below inside the foreach loop was kept on purpose, as no consent reached on such case yet.
Regex used:
assert.+is_object
Comment #12
mero.S CreditAttribution: mero.S as a volunteer and at AnyforSoft for AnyforSoft commentedthank you for explanation)
I will find the next issue
Comment #13
jungleWrong comment in #11, sorry again, in fact, 3 foreach loops in total were touched, one assertion message in one of them was kept on purpose only.
Comment #16
jungleFixing testing failure in #7. Doubt the original code inside
if
never gets executed, as it's always false. -- assertTrue returns void/null?Comment #17
mondrake#16 see #3129074: Refactor assertions that use return values in conditionals
Comment #18
jungleCode snippet from #3129074. Thank you @mondrake! Then I'd postpone this to let #3129074 land first.
Comment #19
catchUnpostponing.
But also this can't be backported to 8.9.x until #3126787: [D8 only] Add forwards-compatibility shim for assertInternalType() replacements in phpunit 6&7 lands.
Comment #20
mondrakeComment #21
jungleRerolled from #16
Comment #22
mondrakeSupposing this is returning back green, it LGTM.
Comment #23
xjmSaving credit.
Comment #26
xjmCommitted to 9.1.x and 9.0.x, thanks!
Next we need an 8.9.x version of the patch to test with the shim.
Comment #27
jungleThanks all!
Rejected file: core/tests/Drupal/KernelTests/Core/Cache/GenericCacheBackendUnitTestBase.php
Comment #28
mondrakeLgtm
Comment #29
xjmComment #30
xjmCommitted the backport to 8.9.x. Thanks!