File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,12 @@ final protected function runTestsInCoroutine(...$arguments)
3737 /* @phpstan-ignore-next-line */
3838 \Swoole \Coroutine \run (function () use (&$ testResult , &$ exception , $ arguments ) {
3939 try {
40+ $ this ->invokeBeforeHookMethods ();
4041 $ testResult = $ this ->{$ this ->realTestName }(...$ arguments );
4142 } catch (Throwable $ e ) {
4243 $ exception = $ e ;
4344 } finally {
45+ $ this ->invokeAfterHookMethods ();
4446 Timer::clearAll ();
4547 CoordinatorManager::until (Constants::WORKER_EXIT )->resume ();
4648 }
@@ -62,4 +64,18 @@ final protected function runTest(): mixed
6264
6365 return parent ::runTest ();
6466 }
67+
68+ private function invokeBeforeHookMethods (): void
69+ {
70+ if (method_exists ($ this , 'beforeTestInCoroutine ' )) {
71+ call_user_func ([$ this , 'beforeTestInCoroutine ' ]);
72+ }
73+ }
74+
75+ private function invokeAfterHookMethods (): void
76+ {
77+ if (method_exists ($ this , 'afterTestInCoroutine ' )) {
78+ call_user_func ([$ this , 'afterTestInCoroutine ' ]);
79+ }
80+ }
6581}
You can’t perform that action at this time.
0 commit comments