[VarDumper][PhpUnitBridge] VarDumperServerListener#26696
Closed
ogizanagi wants to merge 2 commits intosymfony:masterfrom
ogizanagi:feature/phpunit_var_dumper_server_listener
Closed
[VarDumper][PhpUnitBridge] VarDumperServerListener#26696ogizanagi wants to merge 2 commits intosymfony:masterfrom ogizanagi:feature/phpunit_var_dumper_server_listener
ogizanagi wants to merge 2 commits intosymfony:masterfrom
ogizanagi:feature/phpunit_var_dumper_server_listener
Conversation
Contributor
|
Travis failure is not linked to the changes. |
Contributor
Author
|
Closing for now as I didn't find a satisfying enough solution at the time I wrote this PR and didn't take the time to explore more options. |
fabpot
added a commit
that referenced
this pull request
Aug 13, 2020
…nagi) This PR was squashed before being merged into the 5.2-dev branch. Discussion ---------- [VarDumper] Add VAR_DUMPER_FORMAT=server format | Q | A | ------------- | --- | Branch? | master<!-- see below --> | Bug fix? | no | New feature? | yes<!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #35801 <!-- prefix each issue number with "Fix #", if any --> | License | MIT | Doc PR | TODO <!-- required for new features --> This PR follows discussion in #35801 and adds support for a `server` value for the existing `VAR_DUMPER_FORMAT` env var. It comes as well with two more things: - ~~the handler is registered as soon as the `VAR_DUMPER_FORMAT` env var is detected~~ we prevent registering another handler as soon as the `VAR_DUMPER_FORMAT` env var is set, instead of checking if there was a previous handler (which could make this env var useless in some conditions where the handler was already set by another "process") - the handler registered this way cannot be replaced. This prevents another "process" to takeover dump handling while undesired. E.g: a phpunit functional test booting the kernel to call an endpoint => the handler is replaced. It's (in a sense) a satisfying alternative to #26696 This PR means anyone can use dump with a server in any context, without changing a single line of code in the project by: - starting the server using `./vendor/bin/var-dump-server --format=html > dumps.html` - using the env var: `VAR_DUMPER_FORMAT=server [your-cli-command]` --- Previous related PRs: - #26695 - #26696 Commits ------- 82df6db [VarDumper] Add VAR_DUMPER_FORMAT=server format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Based on previous PR (#26695) about easy server dumper as main handler registration.
Keeping exploring different usages for the server dumper feature, this provides a PhpUnit listener you can configure to automatically register the server dumper (allowing to get better context about dumps, cli & html format & avoid mixing the test suite output with wild cli dumps).
Considering the following changes in the symfony-demo
running
vendor/bin/simple-phpunit --filter=BlogControllerTest::testIndexand with server up will generate:giving proper context about the test case in dedicated output instead of this mess:
(of course the output is quite simple here)
However, by setting the
debug.dump_destination:on test env too, and by not locking the handler from the PhpUnit listener, you'll get better context about the controller's dump:but right after the request is executed, the server dumper in use still is the one registered by the
DebugBundle, so we're now loosing the PhpUnit context.So, right now, I don't know how to get the best of both worlds. ogizanagi@23a80bb is an attempt to this, but is not bullet-proof.
Any feedback welcome.