2020use Hyperf \Di \Annotation \AnnotationCollector ;
2121use Hyperf \Di \Annotation \Aspect ;
2222use Hyperf \Di \Aop \Ast ;
23- use Hyperf \Di \BetterReflectionManager ;
23+ use Hyperf \Di \ReflectionManager ;
2424use Hyperf \Utils \ApplicationContext ;
2525use Hyperf \Utils \Context ;
2626use HyperfTest \AsyncQueue \Stub \FooProxy ;
@@ -38,9 +38,12 @@ protected function tearDown(): void
3838 {
3939 Mockery::close ();
4040 Context::set (FooProxy::class, null );
41- BetterReflectionManager ::clear ();
41+ ReflectionManager ::clear ();
4242 }
4343
44+ /**
45+ * @group NonCoroutine
46+ */
4447 public function testNotAsyncMessage ()
4548 {
4649 $ container = $ this ->getContainer ();
@@ -53,6 +56,9 @@ public function testNotAsyncMessage()
5356 $ this ->assertSame ([$ id , $ uuid , $ data ], Context::get (FooProxy::class));
5457 }
5558
59+ /**
60+ * @group NonCoroutine
61+ */
5662 public function testAsyncMessage ()
5763 {
5864 $ container = $ this ->getContainer ();
@@ -65,6 +71,9 @@ public function testAsyncMessage()
6571 $ this ->assertSame ($ data , Context::get (FooProxy::class));
6672 }
6773
74+ /**
75+ * @group NonCoroutine
76+ */
6877 public function testAsyncMessageVariadic ()
6978 {
7079 $ container = $ this ->getContainer ();
@@ -82,20 +91,25 @@ protected function getContainer()
8291 $ container = Mockery::mock (ContainerInterface::class);
8392 ApplicationContext::setContainer ($ container );
8493
85- BetterReflectionManager::initClassReflector ([__DIR__ . '/Stub/ ' ]);
86-
8794 $ aspect = new Aspect ();
8895 $ aspect ->collectClass (AsyncQueueAspect::class);
8996 AnnotationCollector::collectMethod (FooProxy::class, 'async ' , AsyncQueueMessage::class, new AsyncQueueMessage ());
9097 AnnotationCollector::collectMethod (FooProxy::class, 'variadic ' , AsyncQueueMessage::class, new AsyncQueueMessage ());
9198
92- $ ast = new Ast ();
93- $ code = $ ast ->proxy (FooProxy::class);
94- if (! is_dir ($ dir = BASE_PATH . '/runtime/container/proxy/ ' )) {
95- mkdir ($ dir , 0777 , true );
99+ $ pid = pcntl_fork ();
100+ if (! $ pid ) {
101+ $ ast = new Ast ();
102+ $ code = $ ast ->proxy (FooProxy::class);
103+ if (! is_dir ($ dir = BASE_PATH . '/runtime/container/proxy/ ' )) {
104+ mkdir ($ dir , 0777 , true );
105+ }
106+ file_put_contents ($ file = $ dir . 'FooProxy.proxy.php ' , $ code );
107+ exit ;
96108 }
97- file_put_contents ($ file = $ dir . 'FooProxy.proxy.php ' , $ code );
98- require_once $ file ;
109+
110+ pcntl_wait ($ status );
111+
112+ require_once BASE_PATH . '/runtime/container/proxy/FooProxy.proxy.php ' ;
99113
100114 $ container ->shouldReceive ('get ' )->with (FooProxy::class)->andReturn (new FooProxy ());
101115 $ container ->shouldReceive ('get ' )->with (AsyncQueueAspect::class)->andReturnUsing (function ($ _ ) use ($ container ) {
0 commit comments