As #2840538: If parent-child entities are referenced and have the same field name, then nested includes don't work and #2840337: "Invalid nested filtering" with Field Collection entities and more preceding issues show: \Drupal\jsonapi\Context\FieldResolver is not as reliable as it should be. I suspect bugs in this area are the source of most common frustrations/"WTF moments" for JSON API users. So lets' fix that.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers created an issue. See original summary.

Wim Leers’s picture

Title: Add comprehensive unit test coverage for FieldResolver » Add comprehensive unit test coverage for \Drupal\jsonapi\Context\FieldResolver
dremy’s picture

+1 Thanks Wim

dawehner’s picture

Status: Active » Needs review
FileSize
4.95 KB

There we go.

Status: Needs review » Needs work

The last submitted patch, 4: 2842145-4.patch, failed testing.

Wim Leers’s picture

+++ b/tests/src/Kernel/Context/FieldResolverTest.php
@@ -0,0 +1,86 @@
+    \Drupal::requestStack()->pu

PHPLint failure looks legit.

Also WOOHOOO PHPLINTING

dawehner’s picture

Well yeah, this is just a start and I got distracted.

e0ipso’s picture

I believe that the patch provided contains some code from another patch (the one with listings and access).

dawehner’s picture

Status: Needs work » Needs review
FileSize
4.16 KB
5.85 KB

Here is a bit more of a start.

e0ipso’s picture

We should add a field with multiple properties so we can assert:

$this->assertEquals('field_test_ref1.entity.body.format', $this->sut->resolveInternal('field_test_ref1.body.format'));
e0ipso’s picture

Status: Needs review » Needs work
dawehner’s picture

Status: Needs work » Needs review
FileSize
7.19 KB
2.78 KB

Good idea!

  • e0ipso committed 1819338 on 8.x-1.x authored by dawehner
    test(Query Builder) Add comprehensive unit test coverage for \Drupal\...
e0ipso’s picture

Status: Needs review » Fixed

This looks great now!

Status: Fixed » Closed (fixed)

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