function JsonApiRegressionTest::testDeepNestedIncludeMultiTargetEntityTypeFieldFromIssue2973681
Same name and namespace in other branches
- 9 core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testDeepNestedIncludeMultiTargetEntityTypeFieldFromIssue2973681()
- 8.9.x core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testDeepNestedIncludeMultiTargetEntityTypeFieldFromIssue2973681()
- 11.x core/modules/jsonapi/tests/src/Functional/JsonApiRegressionTest.php \Drupal\Tests\jsonapi\Functional\JsonApiRegressionTest::testDeepNestedIncludeMultiTargetEntityTypeFieldFromIssue2973681()
Ensure deep nested include works on multi target entity type field.
See also
https://www.drupal.org/project/drupal/issues/2973681
File
-
core/
modules/ jsonapi/ tests/ src/ Functional/ JsonApiRegressionTest.php, line 55
Class
- JsonApiRegressionTest
- JSON:API regression tests.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
public function testDeepNestedIncludeMultiTargetEntityTypeFieldFromIssue2973681() : void {
// 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->createEntityReferenceField('node', 'page', 'field_comment', NULL, 'comment', 'default', [
'target_bundles' => [
'comment' => 'comment',
'tcomment' => 'tcomment',
],
], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
$this->rebuildAll();
// Create data.
$node = Node::create([
'title' => 'test article',
'type' => 'article',
]);
$node->save();
$comment = Comment::create([
'subject' => 'Llama',
'entity_id' => 1,
'entity_type' => 'node',
'field_name' => 'comment',
]);
$comment->save();
$page = Node::create([
'title' => 'test node',
'type' => 'page',
'field_comment' => [
'entity' => $comment,
],
]);
$page->save();
// Test.
$user = $this->drupalCreateUser([
'access content',
'access comments',
]);
$response = $this->request('GET', Url::fromUri('internal:/jsonapi/node/page?include=field_comment,field_comment.entity_id,field_comment.entity_id.uid'), [
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.