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.
TL;DR
This is a working example of behavior test. Consider workerman as a black box server and verify tests as clients.
As discussed in #904 , I mentioned the behavior test is not doable because pest lacks supporting for isolation process tests. However, after experiments with PhpUnit, I realized @runinseparateprocess doesn't help as well. The only programming way to kill the service itself from inside is to kill the whole process, but even for PhpUnit it still requires to do certain jobs after the test method(s). Killing the proces is considered as an error and will leads to a test failure.
This PR proposed a different way for such tests. Instead of trying to asset values on both side, we consider the server side as a black box and only pay attention to the value we sent and received as a client. To archive this, we create a new process during
beforeAll
/setUp
(with the help of symfony'sPhpProcess
) and stop it duringafterAll
/tearDown
. Thus all tests in same file/class can communicate with the server and checking the server's behavior.p.s. a not-so-small suggestion. Tests are not just about adding more test cases. Workerman also needs to be changed/modified to enable better and more comprehensive tests. e.g. When I tried to start workerman, the only way I found is to override
$argv
. There is astatic::$command
andgetArgv
inWorker
so I guess the author does have an intention to support such use case. However,parseCommand
still only use$argv
as the only input, which make$command
much less useful.