$unparseable_request_body = '!{>}<';
$parseable_valid_request_body =
$this->serializer->
encode($this->
getNormalizedPostEntity(),
static::
$format);
$parseable_invalid_request_body =
$this->serializer->
encode($this->
makeNormalizationInvalid($this->
getNormalizedPostEntity(), 'label'
),
static::
$format);
$parseable_invalid_request_body_2 =
$this->serializer->
encode($this->
getNormalizedPostEntity() +
['uuid' =>
[$this->
randomMachineName(129
)]],
static::
$format);
$parseable_invalid_request_body_3 =
$this->serializer->
encode($this->
getNormalizedPostEntity() +
['field_rest_test' =>
[['value' =>
$this->
randomString()]]],
static::
$format);
// The URL and Guzzle request options that will be used in this test. The
// request options will be modified/expanded throughout this test:
// - to first test all mistakes a developer might make, and assert that the
// error responses provide a good DX
// - to eventually result in a well-formed request that succeeds.
$url =
$this->
getEntityResourcePostUrl();
$request_options =
[];
// DX: 404 when resource not provisioned. HTML response because missing
// ?_format query string.
$response =
$this->
request('POST',
$url,
$request_options);
$this->
assertSame(404,
$response->
getStatusCode());
$this->
assertSame(['text/html; charset=UTF-8'
],
$response->
getHeader('Content-Type'
));
$url->
setOption('query',
['_format' =>
static::
$format]);
// DX: 404 when resource not provisioned.