You are here

public function EntityResourceTest::testPatchRelationshipInternal in JSON:API 8

@covers ::patchRelationship

File

tests/src/Kernel/Controller/EntityResourceTest.php, line 820

Class

EntityResourceTest
@coversDefaultClass \Drupal\jsonapi\Controller\EntityResource @group jsonapi @group legacy

Namespace

Drupal\Tests\jsonapi\Kernel\Controller

Code

public function testPatchRelationshipInternal() {
  $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
    ->patchRelationship($this->node, 'field_relationships', $list, new Request());
}