public function EntityResourceTest::testCreateRelationshipInternal in JSON:API 8
@covers ::createRelationship
File
- tests/
src/ Kernel/ Controller/ EntityResourceTest.php, line 802
Class
- EntityResourceTest
- @coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy
Namespace
Drupal\Tests\jsonapi\Kernel\ControllerCode
public function testCreateRelationshipInternal() {
$internal_resource_type = new ResourceType('node', 'article', NULL, TRUE);
$resource = $this
->buildEntityResource('node', 'article', [
'field_relationships' => [
$internal_resource_type,
],
]);
Role::load(Role::ANONYMOUS_ID)
->grantPermission('edit any article content')
->save();
$field_type_manager = $this->container
->get('plugin.manager.field.field_type');
$list = $field_type_manager
->createFieldItemList($this->node, 'field_relationships');
$this
->setExpectedException(NotFoundHttpException::class);
$resource
->createRelationship($this->node, 'field_relationships', $list, new Request());
}