-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[FrameworkBundle][HttpFoundation] reduce response constraints verbosity #49184
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
[FrameworkBundle][HttpFoundation] reduce response constraints verbosity #49184
Conversation
78772a9
to
ab0eea3
Compare
ab0eea3
to
54c1bbb
Compare
Hey! I think @alli83 has recently worked with this code. Maybe they can help review this? Cheers! Carsonbot |
Hi Nicolas! Thank you for submitting this pull request and for all the hard work you put into it. I appreciate your effort and dedication to improving this project. However, after reviewing your changes, I'm not entirely sure if your solution is necessary or if using |
Catching exception effectively reduces the verbosity. This PR intends to reduces the verbosity of test logs in all cases. For example, a failed assertion about response status code will dump the entire response, including body. |
@Nicals Are you still interested in finishing this PR? |
c9f5ae0
to
7d0265c
Compare
@fabpot I totally forgot about this MR. I don't work with php/symfony anymore so I did not keep track of it. I quickly rebased this branch on up to date 7.1 and built the response headers manually. |
7d0265c
to
cabb2dc
Compare
Thank you @Nicals. |
…priou) This PR was submitted for the 6.3 branch but it was merged into the 7.1 branch instead. Discussion ---------- 42948 reduce response contraints verbosity Link the issue [#49184](symfony/symfony#49184), and [PR](symfony/symfony#49184). Update signature of HTTP response constraints. Commits ------- d159a4a [HttpFoundation] Update http response test constraint signature
Adds a
verbose
argument to HttpFoundation response test constraints.If set to false, only the HTTP response command and headers will be displayed in case of test failure.
This argument is
true
by default to keep backward compatibility, but I think it would make more sense to befalse
.Before
After
I added a method
Symfony\Component\HttpFoundation\Response::getCommandString()
that builds the first line of an HTTP response to avoid code duplication in constraints classes.I thought of other solutions:
Constraint
. This seems that too much code duplication.AbstractResponseConstraint
with a utility method to build a less verbose response string. I wasn't sure we needed to add an extend layer here.ResponseConstraintTrait
with an exposed method to build the less verbose response string. This did not feel right.Overall, I think the
Response
class is the more appropriate to build this string.I also had some issue with psalm complaining about the documented $response argument type of
additionalFailureDescription
:I needed to delete the phpdoc comment to comply with this. I only changed the lines were Psalm was giving me errors, but there are still some mismatch between HttpFoundation constraints signatures and PHPUnit ones.