You are here

public function ConfigurableLanguageTest::testGetIndividualDefaultConfig in JSON:API 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/ConfigurableLanguageTest.php \Drupal\Tests\jsonapi\Functional\ConfigurableLanguageTest::testGetIndividualDefaultConfig()

Test a GET request for a default config entity, which has a _core key.

See also

https://www.drupal.org/project/jsonapi/issues/2915539

File

tests/src/Functional/ConfigurableLanguageTest.php, line 117

Class

ConfigurableLanguageTest
JSON:API integration test for the "ConfigurableLanguage" config entity type.

Namespace

Drupal\Tests\jsonapi\Functional

Code

public function testGetIndividualDefaultConfig() {

  // @todo Remove line below in favor of commented line in https://www.drupal.org/project/jsonapi/issues/2878463.
  $url = Url::fromRoute('jsonapi.configurable_language--configurable_language.individual', [
    'entity' => ConfigurableLanguage::load('en')
      ->uuid(),
  ]);

  /* $url = ConfigurableLanguage::load('en')->toUrl('jsonapi'); */
  $request_options = [];
  $request_options[RequestOptions::HEADERS]['Accept'] = 'application/vnd.api+json';
  $request_options = NestedArray::mergeDeep($request_options, $this
    ->getAuthenticationRequestOptions());
  $this
    ->setUpAuthorization('GET');
  $response = $this
    ->request('GET', $url, $request_options);
  $normalization = Json::decode((string) $response
    ->getBody());
  $this
    ->assertArrayNotHasKey('_core', $normalization['data']['attributes']);
}