function JsonApiFunctionalMultilingualTest::testDeleteMultilingual

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalMultilingualTest.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalMultilingualTest::testDeleteMultilingual()
  2. 8.9.x core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalMultilingualTest.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalMultilingualTest::testDeleteMultilingual()
  3. 10 core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalMultilingualTest.php \Drupal\Tests\jsonapi\Functional\JsonApiFunctionalMultilingualTest::testDeleteMultilingual()

Tests deleting multilingual content.

File

core/modules/jsonapi/tests/src/Functional/JsonApiFunctionalMultilingualTest.php, line 306

Class

JsonApiFunctionalMultilingualTest
Tests JSON:API multilingual support.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testDeleteMultilingual() : void {
    $this->config('jsonapi.settings')
        ->set('read_only', FALSE)
        ->save(TRUE);
    $this->grantPermissions(Role::load(RoleInterface::ANONYMOUS_ID), [
        'bypass node access',
    ]);
    $response = $this->request('DELETE', Url::fromUri('base:/ca/jsonapi/node/article/' . $this->nodes[0]
        ->uuid()), []);
    $this->assertSame(405, $response->getStatusCode());
    $document = $this->getDocumentFromResponse($response, FALSE);
    $this->assertSame('Deleting a resource object translation is not yet supported. See https://www.drupal.org/docs/8/modules/jsonapi/translations.', $document['errors'][0]['detail']);
    $response = $this->request('DELETE', Url::fromUri('base:/ca-fr/jsonapi/node/article/' . $this->nodes[0]
        ->uuid()), []);
    $this->assertSame(405, $response->getStatusCode());
    $document = $this->getDocumentFromResponse($response, FALSE);
    $this->assertSame('Deleting a resource object translation is not yet supported. See https://www.drupal.org/docs/8/modules/jsonapi/translations.', $document['errors'][0]['detail']);
    $response = $this->request('DELETE', Url::fromUri('base:/jsonapi/node/article/' . $this->nodes[0]
        ->uuid()), []);
    $this->assertSame(204, $response->getStatusCode());
    $this->assertNull(Node::load($this->nodes[0]
        ->id()));
}

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