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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bbrala created an issue. See original summary.

bbrala’s picture

Berdir’s picture

Status: Active » Needs work
+++ b/core/modules/jsonapi/tests/src/Functional/BlockContentTest.php
@@ -200,7 +200,8 @@ protected function getExpectedCacheContexts(array $sparse_fieldset = NULL) {
    */
   public function testRelated() {
-    $this->markTestSkipped('Remove this in https://www.drupal.org/project/jsonapi/issues/2940339');
+    // $this->markTestSkipped('Remove this in https://www.drupal.org/project/jsonapi/issues/2940339');
+    parent::testRelated();
   }

You 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

bbrala’s picture

Yeah they should be removed i know, thought it would apply anyways though. Guess not. :)

i'll update the patch.

bbrala’s picture

Issue summary: View changes
bbrala’s picture

bbrala’s picture

Status: Needs work » Needs review
bbrala’s picture

Status: Needs review » Needs work
Wim Leers’s picture

The patch does not apply, could you please reroll? :)

bbrala’s picture

Yeah will do when i get home, didn't have the energy to fix it yesterday :)

bbrala’s picture

I've forced git to treat all files as text. This should fix the apply.

ravi.shankar’s picture

Status: Needs work » Needs review
bbrala’s picture

This is not a working patch, why should it be 'needs review'?

ravi.shankar’s picture

Status: Needs review » Needs work
amateescu’s picture

Note 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.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

ridhimaabrol24’s picture

vsujeetkumar’s picture

Status: Needs work » Needs review
FileSize
3.21 KB
2.5 KB

Fixing test, Please review.

Status: Needs review » Needs work

The last submitted patch, 18: 3093757_18.patch, failed testing. View results

Deepak Goyal’s picture

Assigned: Unassigned » Deepak Goyal
Deepak Goyal’s picture

Assigned: Deepak Goyal » Unassigned
jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
1.44 KB
3.95 KB

After 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 to getEmptyCollectionResponse() should be 1, while currently FALSE 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.

bbrala’s picture

I'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).

bbrala’s picture

The one failure is also on the dev branch, so unrelated to this patch.

bbrala’s picture

Status: Needs review » Reviewed & tested by the community

The patch is good, I only changed another call. Gonna flag as RTBC.

xjm’s picture

Status: Reviewed & tested by the community » Needs review

Thanks 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!

bbrala’s picture

FileSize
831 bytes

Will 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.

bbrala’s picture

FileSize
831 bytes
JordanDukart’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed, looks good to me!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 23: 3093757-23.patch, failed testing. View results

bbrala’s picture

Status: Needs work » Reviewed & tested by the community

As always, the QuickEdit test is failing. Completely unrelated. Settings it back to RTBC

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

This needs a re-roll against 9.1.x

bbrala’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
4.57 KB

Unfortunate :)

I rerolled it for 9.1.x, thanks.

catch’s picture

Status: Reviewed & tested by the community » Needs work
bbrala’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
4.59 KB

Hehe, indeed you did @catch, no problem though. A quick fix is possible.

  • catch committed 1e06a3e on 9.1.x
    Issue #3093757 by bbrala, vsujeetkumar, jofitz, ridhimaabrol24, Berdir,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 1e06a3e and pushed to 9.1.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.