$user = TestUser::
createNewTestUser($connection,
['country:create', 'country:read'
]);
$admin = TestUser::
getAdmin();
$user->
authorizeBrowser($browser);
$browser->
request('POST', '/api/country',
[],
[],
[],
json_encode($data, \JSON_THROW_ON_ERROR
));
$response =
$browser->
getResponse();
static::
assertSame(Response::HTTP_NO_CONTENT,
$browser->
getResponse()->
getStatusCode(),
(string) $browser->
getResponse()->
getContent());
static::
assertNotEmpty($response->headers->
get('Location'
));
static::
assertEquals('http://localhost/api/country/' .
$id,
$response->headers->
get('Location'
));
$this->
assertEntityExists($browser, 'country',
$id);
$data =
[ 'id' =>
$id,
'name' => 'test_state',
'shortCode' => 'test',
];
$browser->
request('POST', '/api/country/' .
$id . '/states/',
[],
[],
[],
json_encode($data, \JSON_THROW_ON_ERROR
));
$response =
$browser->
getResponse();
static::
assertSame(Response::HTTP_FORBIDDEN,
$response->
getStatusCode(),
(string) $response->
getContent());