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.
There are a few places in the jsonapi tests where there is a reference to issue #2940339. It states that the testRelated
test should be re-enabled when that issue is fixed. This didn't happen.
I tried just removing the skips, but it seems there is still some work to be done to make sure the code in testRelated
can handle NULL
. Currently the tests fails as follows:
The 'data' member was not as expected.
Failed asserting that null is identical to Array &0 ().
/home/localcopy/drupal/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php:789
/home/localcopy/drupal/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php:715
/home/localcopy/drupal/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php:1377
/home/localcopy/drupal/core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php:1296
/home/localcopy/drupal/core/modules/jsonapi/tests/src/Functional/CommentTest.php:396
I added a patch with the tests enabled inline to make debugging easier.
Comment | File | Size | Author |
---|---|---|---|
#35 | 3093757-35.patch | 4.59 KB | bbrala |
#33 | 3093757-33.patch | 4.57 KB | bbrala |
#28 | interdiff-3093757-22-23.txt | 831 bytes | bbrala |
#23 | 3093757-23.patch | 4.57 KB | bbrala |
#22 | 3093757-22.patch | 3.95 KB | jofitz |
Comments
Comment #2
bbralaComment #3
BerdirYou should just remove these methods instead. Also make sure to set the status to needs review when you upload a patch.
Also your patch sees MenuLinkContentTest as a binary file, maybe due to special characters in there? Probably Wim and his love for emojis causing problems again :p
Comment #4
bbralaYeah they should be removed i know, thought it would apply anyways though. Guess not. :)
i'll update the patch.
Comment #5
bbralaComment #6
bbralaComment #7
bbralaComment #8
bbralaComment #9
Wim LeersThe patch does not apply, could you please reroll? :)
Comment #10
bbralaYeah will do when i get home, didn't have the energy to fix it yesterday :)
Comment #11
bbralaI've forced git to treat all files as text. This should fix the apply.
Comment #12
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedComment #13
bbralaThis is not a working patch, why should it be 'needs review'?
Comment #14
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedComment #15
amateescu CreditAttribution: amateescu for Pfizer, Inc. commentedNote that the patch from #3088870-25: Add missing REST and JSON:API test coverage for the workspace entity type has the same failure in the
testRelated()
method as the ones exposed by #11, so this issue should handle that one as well if it gets committed first.Comment #17
ridhimaabrol24 CreditAttribution: ridhimaabrol24 at Srijan | A Material+ Company for Drupal India Association commentedComment #18
vsujeetkumar CreditAttribution: vsujeetkumar at Srijan | A Material+ Company for Drupal India Association commentedFixing test, Please review.
Comment #20
Deepak Goyal CreditAttribution: Deepak Goyal at Srijan | A Material+ Company for Drupal India Association commentedComment #21
Deepak Goyal CreditAttribution: Deepak Goyal at Srijan | A Material+ Company for Drupal India Association commentedComment #22
jofitz CreditAttribution: jofitz at jofitz commentedAfter more hours than I'm willing to admit(!), I believe I have come up with the solution to the test failures from the patch in #11 (I think the patches in #17 and #18 are red-herrings - this is a tough issue to debug).
The interdiff may not appear clear immediately, but basically if
$relationship_document['data']
is null the the cardinality passed togetEmptyCollectionResponse()
should be1
, while currentlyFALSE
is passed.I believe this will still pass even once #3088870: Add missing REST and JSON:API test coverage for the workspace entity type has been committed.
Comment #23
bbralaI've looked through you patch and it seems like it does fix it that specific instance.
What i did notice is the argument for the
getEmptyCollectionResponse
is rather weird and might actually be the source of another test that is might not work as expected. Before your patch it is used twice, both times it is fed a boolean. But the check in the method does:'data' => $cardinality === 1 ? NULL : [],
so when a boolean is passed this should always fail and assume an infinite relation.If the function signature (or at least the dockblock) does imply using 1 or -1 as the value. I rolled a patch with the other call fixed (line 1863 in
ResourceTestBase.php
).Comment #24
bbralaThe one failure is also on the dev branch, so unrelated to this patch.
Comment #25
bbralaThe patch is good, I only changed another call. Gonna flag as RTBC.
Comment #26
xjmThanks for working on this. It's always great to be able to remove technical debt like this.
@bbrala, in the future, provide interdiffs for your patches. That allows reviewers to evaluate your changes.
Also, in general, it's only allowable to RTBC one's one patch if the change is trivial and does not affect the functionality (e.g., fixing a couple of small coding standards issues or rewording a comment). I'm setting the issue back to "Needs review" for a peer review -- you can upload the interdiff, and other issue contributors can help decide if it also makes sense. Thanks!
Comment #27
bbralaWill do, interdiff wasn't available at the moment i created the patch, will take care to always add those in the future..
I was contemplating if i would flag as reviewed since i kinda reviewed his changes and added a little bit, But i'll be a bit more defensive next time. Cheers.
Comment #28
bbralaComment #29
JordanDukart CreditAttribution: JordanDukart as a volunteer commentedReviewed, looks good to me!
Comment #31
bbralaAs always, the QuickEdit test is failing. Completely unrelated. Settings it back to RTBC
Comment #32
catchThis needs a re-roll against 9.1.x
Comment #33
bbralaUnfortunate :)
I rerolled it for 9.1.x, thanks.
Comment #34
catchOof I think I just made this not apply yet again by committing #3072076: JSON:API returns a CacheableResponseInterface instance for non-cacheable methods; causes unnecessary exceptions.... :/
Comment #35
bbralaHehe, indeed you did @catch, no problem though. A quick fix is possible.
Comment #37
catchCommitted 1e06a3e and pushed to 9.1.x. Thanks!