function JsonApiFilterRegressionTest::testBundleSpecificTargetEntityTypeFromIssue2953207
Same name in other branches
- 10 core/modules/jsonapi/tests/src/Functional/JsonApiFilterRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiFilterRegressionTest::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/ JsonApiFilterRegressionTest.php, line 47
Class
- JsonApiFilterRegressionTest
- JSON:API regression tests.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
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.