function JsonApiPatchRegressionTest::testBundleSpecificTargetEntityTypeFromIssue2953207

Same name and namespace in other branches
  1. 10 core/modules/jsonapi/tests/src/Functional/JsonApiPatchRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiPatchRegressionTest::testBundleSpecificTargetEntityTypeFromIssue2953207()

Ensure filtering on relationships works with bundle-specific target types.

See also

https://www.drupal.org/project/drupal/issues/2953207

File

core/modules/jsonapi/tests/src/Functional/JsonApiPatchRegressionTest.php, line 50

Class

JsonApiPatchRegressionTest
JSON:API regression tests.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testBundleSpecificTargetEntityTypeFromIssue2953207() : void {
  // Set up data model.
  $this->assertTrue($this->container
    ->get('module_installer')
    ->install([
    'comment',
  ], TRUE), 'Installed modules.');
  $this->addDefaultCommentField('taxonomy_term', 'tags', 'comment', CommentItemInterface::OPEN, 'test_comment_type');
  $this->rebuildAll();
  // Create data.
  Term::create([
    'name' => 'foobar',
    'vid' => 'tags',
  ])->save();
  Comment::create([
    'subject' => 'Llama',
    'entity_id' => 1,
    'entity_type' => 'taxonomy_term',
    'field_name' => 'comment',
  ])->save();
  // Test.
  $user = $this->drupalCreateUser([
    'access comments',
  ]);
  $response = $this->request('GET', Url::fromUri('internal:/jsonapi/comment/test_comment_type?include=entity_id&filter[entity_id.name]=foobar'), [
    RequestOptions::AUTH => [
      $user->getAccountName(),
      $user->pass_raw,
    ],
  ]);
  $this->assertSame(200, $response->getStatusCode());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.