src/Context/FieldResolver.php | 4 ++-- tests/src/Functional/JsonApiRegressionTest.php | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Context/FieldResolver.php b/src/Context/FieldResolver.php index 1165765..ff44680 100644 --- a/src/Context/FieldResolver.php +++ b/src/Context/FieldResolver.php @@ -84,13 +84,13 @@ class FieldResolver { */ public static function validateIncludePath(ResourceType $resource_type, array $path_parts) { if (empty($path_parts)) { - throw new BadRequestHttpException("Empty include path."); + throw new BadRequestHttpException('Empty include path.'); } $field_name = $resource_type->getInternalName($path_parts[0]); $relatable_resource_types = $resource_type->getRelatableResourceTypesByField($field_name); if (empty($relatable_resource_types)) { $possible = implode(', ', array_keys($resource_type->getRelatableResourceTypes())); - throw new BadRequestHttpException("$field_name is not a valid relationship field name. Possible values: $possible"); + throw new BadRequestHttpException("$field_name is not a valid relationship field name. Possible values: $possible."); } $remaining_parts = array_slice($path_parts, 1); if (empty($remaining_parts)) { diff --git a/tests/src/Functional/JsonApiRegressionTest.php b/tests/src/Functional/JsonApiRegressionTest.php index 25615dc..80af499 100644 --- a/tests/src/Functional/JsonApiRegressionTest.php +++ b/tests/src/Functional/JsonApiRegressionTest.php @@ -24,24 +24,16 @@ class JsonApiRegressionTest extends JsonApiFunctionalTestBase { use CommentTestTrait; /** - * {@inheritdoc} + * Ensure filtering on relationships works with bundle-specific target types. + * + * @see https://www.drupal.org/project/jsonapi/issues/2953207 */ - protected function setUp() { - parent::setUp(); + public function testBundleSpecificTargetEntityTypeFromIssue2953207() { // Set up data model. $this->assertTrue($this->container->get('module_installer')->install(['comment'], TRUE), 'Installed modules.'); - $this->addDefaultCommentField('node', 'article'); $this->addDefaultCommentField('taxonomy_term', 'tags', 'comment', CommentItemInterface::OPEN, 'tcomment'); - $this->drupalCreateContentType(['type' => 'page']); $this->rebuildAll(); - } - /** - * Ensure filtering on relationships works with bundle-specific target types. - * - * @see https://www.drupal.org/project/jsonapi/issues/2953207 - */ - public function testBundleSpecificTargetEntityTypeFromIssue2953207() { // Create data. Term::create([ 'name' => 'foobar', @@ -73,6 +65,13 @@ class JsonApiRegressionTest extends JsonApiFunctionalTestBase { * @see https://www.drupal.org/project/jsonapi/issues/2973681 */ public function testDeepNestedIncludeMultiTargetEntityTypeFieldFromIssue2973681() { + // Set up data model. + $this->assertTrue($this->container->get('module_installer')->install(['comment'], TRUE), 'Installed modules.'); + $this->addDefaultCommentField('node', 'article'); + $this->addDefaultCommentField('taxonomy_term', 'tags', 'comment', CommentItemInterface::OPEN, 'tcomment'); + $this->drupalCreateContentType(['type' => 'page']); + $this->rebuildAll(); + $this->createEntityReferenceField( 'node', 'page',