@@ -56,25 +56,41 @@ public function testGetDataKeyInCoroutine()
5656 {
5757 $ data1 = null ;
5858 $ data2 = null ;
59+ $ data3 = null ;
60+
5961 $ coroutineId1 = null ;
6062 $ coroutineId2 = null ;
61- \Swoole \Coroutine \run (function () use (&$ data1 , &$ data2 , &$ coroutineId1 , &$ coroutineId2 ) {
63+ $ coroutineId3 = null ;
64+
65+ \Swoole \Coroutine \run (function () use (&$ data1 , &$ data2 , &$ data3 , &$ coroutineId1 , &$ coroutineId2 , &$ coroutineId3 ) {
6266 Context::setData ('foo ' , 'bar ' );
6367
6468 $ data1 = Context::getData ('foo ' );
6569 $ data2 = 'baz ' ;
70+ $ data2 = 'swoole ' ;
71+
6672 $ coroutineId1 = Context::getRequestedCoroutineId ();
6773 $ coroutineId2 = -1 ;
74+ $ coroutineId3 = -1 ;
6875
69- go (function () use (&$ data2 , &$ coroutineId2 ) {
76+ go (function () use (&$ data2 , &$ data3 , & $ coroutineId2, & $ coroutineId3 ) {
7077 $ data2 = Context::getData ('foo ' );
7178 $ coroutineId2 = Context::getRequestedCoroutineId ();
79+
80+ // test nested coroutine
81+ go (function () use (&$ data3 , &$ coroutineId3 ) {
82+ $ data3 = Context::getData ('foo ' );
83+ $ coroutineId3 = Context::getRequestedCoroutineId ();
84+ });
7285 });
7386 });
7487
7588 $ this ->assertSame ('bar ' , $ data1 );
7689 $ this ->assertSame ($ data1 , $ data2 );
90+ $ this ->assertSame ($ data2 , $ data3 );
7791 $ this ->assertSame ($ coroutineId1 , $ coroutineId2 );
92+ $ this ->assertSame ($ coroutineId2 , $ coroutineId3 );
93+
7894 }
7995
8096 public function testClear ()
0 commit comments