'symfony ApiTestCase to tests post method
I tried to make a simple post test api with ApiTestCase with symfony.
I tried two methods to pass the post data
$response = static::createClient()->request('POST', '/task/create',
[
'body' => [
'name' => 'test',
'description' => 'The Handmaid\'s Tale',
]
]
);
$response = static::createClient()->request('POST', '/task/create', ['json' => [
'name' => 'test',
'description' => 'The Handmaid\'s Tale',
]]);
For both exemples I got this message error
An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null
I know what it is but the issue here it is like the data wasn't sent or seen by the request, how can I resolve this issue, Thanks.
The controller to get all data in body :
$data = $request->request->all();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
