$response =
$this->
request('GET',
$url,
$request_options);
$this->
assertSame(200,
$response->
getStatusCode());
$response = Json::
decode((string) $response->
getBody());
$this->
assertArrayNotHasKey('included',
$response, 'JSON API response does not contain "included" taxonomy term as the latter is not published, i.e not accessible.'
);
$omitted =
$response['meta'
]['omitted'
]['links'
];
unset($omitted['help'
]);
$omitted =
reset($omitted);
$expected_url = Url::
fromUri('internal:/jsonapi/' .
$term->
getEntityTypeId() . '/' .
$term->
bundle() . '/' .
$term->
uuid());
$expected_url->
setAbsolute();
$this->
assertSame($expected_url->
toString(),
$omitted['href'
], 'Entity that is excluded due to access constraints is correctly reported in the "Omitted" section of the JSON API response.'
);
$term->
setPublished();
$term->
save();
$response =
$this->
request('GET',
$url,
$request_options);
$this->
assertSame(200,
$response->
getStatusCode());
$this->
assertEquals($term->
uuid(), Json::
decode((string) $response->
getBody())['included'
][0
]['id'
], 'JSON API response contains "included" taxonomy term as it became published, i.e accessible.'
);
} /**
* Tests that "virtual/missing" resources can exist for renamed fields.
*
* @see https://www.drupal.org/project/drupal/issues/3034786
* @see https://www.drupal.org/project/drupal/issues/3035544
*/