From 8a58b6924344a0fa6caa0ddb6596a447d72b2309 Mon Sep 17 00:00:00 2001 From: sunxyw Date: Sat, 18 Feb 2023 21:04:36 +0800 Subject: [PATCH] fix phpunit not bootstrapped --- bin/phpunit-zm | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/phpunit-zm b/bin/phpunit-zm index 70ad6d20..ae1717a2 100755 --- a/bin/phpunit-zm +++ b/bin/phpunit-zm @@ -52,11 +52,18 @@ ob_event_provider()->addEventListener(WorkerStartEvent::getName(), function () { } }, 1); +$options = ServerStartCommand::exportOptionArray(); +$options['driver'] = 'workerman'; +$options['worker-num'] = 1; +$options['private-mode'] = true; + +// TODO: optimize this, maybe abstract the application (framework) +$bootstrappers = new ReflectionProperty(\ZM\ConsoleApplication::class, 'bootstrappers'); +foreach ($bootstrappers->getDefaultValue() as $bootstrapper) { + resolve($bootstrapper)->bootstrap($options); +} + try { - $options = ServerStartCommand::exportOptionArray(); - $options['driver'] = 'workerman'; - $options['worker-num'] = 1; - $options['private-mode'] = true; (new Framework($options))->init()->start(); exit($_swoole_atomic->get()); } catch (Throwable $e) {