-
-
Notifications
You must be signed in to change notification settings - Fork 374
It parses "Content-Disposition: form-data" incorrectly for list arrays #2010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Thank you. Given how extensive/risky the changes are for this specific behavior, it would be great to have unit tests that cover all the different scenarios (in the sense that we have many branches of code and we'd want all of them covered). Doing that via high level tests would be very verbose and complex, so I'd leave the tests that you've added to cover the main paths, they are great. Could you add lower level unit tests in bref/tests/Event/Http/Psr7BridgeTest.php Line 18 in 30a3e47
|
|
@mnapoli About the Psr7BridgeTest test, I'll just add the same test but manually creating HttpRequestEvent like: $event = new HttpRequestEvent(json_decode(file_get_contents('can I still use fixture file?'), true, 512, JSON_THROW_ON_ERROR));
$request = Psr7Bridge::convertRequest($event, Context::fake());
$this->assertEquals([parsed body], $request->getParsedBody());to avoid using abstractions? What about 2 event versions? |
|
Yes exactly, but you wouldn't even have to use an external file (fixture file), you can have the sample data directly in the PHP test for these unit tests. That allows to create many small (unit) tests to check each scenario. Ideally we'd like some code coverage of all the lines you are adding to the project, because these will be hard to maintain considering the complexity. |
|
@mnapoli I can add a unit test for that specific function |
|
@mnapoli I added a separate test only for the |
|
OK, we don't want a separate test class, and we don't want to use reflection to test the private method. Here's an example of what would work well: public function test xxx()
{
$event = new HttpRequestEvent([
...
]);
$request = Psr7Bridge::convertRequest($event, Context::fake());
$this->assertEquals([
...
], $request->getParsedBody());
}And we need enough tests like these to cover all the scenarios that the new code supports (e.g. using code coverage). |
|
@mnapoli Ok, I added more comprehensive test to Psr7BridgeTest |
Following: brefphp/laravel-bridge#189
It parses "Content-Disposition: form-data" incorrectly for list arrays, specifically in arrays like:
It parses into separate array objects:
But it should parse into: