$request_options =
[];
$request_options[RequestOptions::HEADERS
]['Accept'
] = 'application/vnd.api+json';
$request_options[RequestOptions::HEADERS
]['Content-Type'
] = 'application/vnd.api+json';
$request_options = NestedArray::
mergeDeep($request_options,
$this->
getAuthenticationRequestOptions());
$remove_field =
function Darray
$normalization,
$type,
$attribute_name) { unset($normalization['data'
][$type][$attribute_name]);
return $normalization;
};
// DX: 422 when missing 'entity_type' field.
$request_options[RequestOptions::BODY
] = Json::
encode($remove_field($this->
getPostDocument(), 'attributes', 'entity_type'
));
$response =
$this->
request('POST',
$url,
$request_options);
$this->
assertResourceErrorResponse(422, 'entity_type: This value should not be null.', NULL,
$response, '/data/attributes/entity_type'
);
// DX: 422 when missing 'entity_id' field.
$request_options[RequestOptions::BODY
] = Json::
encode($remove_field($this->
getPostDocument(), 'relationships', 'entity_id'
));
// @todo Remove the try/catch in https://www.drupal.org/node/2820364.
try { $response =
$this->
request('POST',
$url,
$request_options);
$this->
assertResourceErrorResponse(422, 'entity_id: This value should not be null.', NULL,
$response, '/data/attributes/entity_id'
);
} catch (\Exception
$e) {