/**
* Tests using the file upload POST route.
*/
public function testPostFileUpload() { $this->
initAuthentication();
$this->
provisionResource([static::
$format],
static::
$auth ?
[static::
$auth] :
[],
['POST'
]);
$uri = Url::
fromUri('base:' .
static::
$postUri);
// DX: 403 when unauthorized.
$response =
$this->
fileRequest($uri,
$this->testFileData
);
$this->
assertResourceErrorResponse(403,
$this->
getExpectedUnauthorizedAccessMessage('POST'
),
$response);
$this->
setUpAuthorization('POST'
);
// 404 when the field name is invalid.
$invalid_uri = Url::
fromUri('base:file/upload/entity_test/entity_test/field_rest_file_test_invalid'
);
$response =
$this->
fileRequest($invalid_uri,
$this->testFileData
);
$this->
assertResourceErrorResponse(404, 'Field "field_rest_file_test_invalid" does not exist',
$response);
// This request will have the default 'application/octet-stream' content
// type header.