@@ -56,25 +56,41 @@ public function testGetDataKeyInCoroutine()
56
56
{
57
57
$ data1 = null ;
58
58
$ data2 = null ;
59
+ $ data3 = null ;
60
+
59
61
$ coroutineId1 = null ;
60
62
$ 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 ) {
62
66
Context::setData ('foo ' , 'bar ' );
63
67
64
68
$ data1 = Context::getData ('foo ' );
65
69
$ data2 = 'baz ' ;
70
+ $ data2 = 'swoole ' ;
71
+
66
72
$ coroutineId1 = Context::getRequestedCoroutineId ();
67
73
$ coroutineId2 = -1 ;
74
+ $ coroutineId3 = -1 ;
68
75
69
- go (function () use (&$ data2 , &$ coroutineId2 ) {
76
+ go (function () use (&$ data2 , &$ data3 , & $ coroutineId2, & $ coroutineId3 ) {
70
77
$ data2 = Context::getData ('foo ' );
71
78
$ coroutineId2 = Context::getRequestedCoroutineId ();
79
+
80
+ // test nested coroutine
81
+ go (function () use (&$ data3 , &$ coroutineId3 ) {
82
+ $ data3 = Context::getData ('foo ' );
83
+ $ coroutineId3 = Context::getRequestedCoroutineId ();
84
+ });
72
85
});
73
86
});
74
87
75
88
$ this ->assertSame ('bar ' , $ data1 );
76
89
$ this ->assertSame ($ data1 , $ data2 );
90
+ $ this ->assertSame ($ data2 , $ data3 );
77
91
$ this ->assertSame ($ coroutineId1 , $ coroutineId2 );
92
+ $ this ->assertSame ($ coroutineId2 , $ coroutineId3 );
93
+
78
94
}
79
95
80
96
public function testClear ()
0 commit comments