@@ -49,26 +49,52 @@ public function testInvoke(): void
49
49
Call::create ('getBody ' )->with ()->willReturn ($ responseBody ),
50
50
]);
51
51
52
- /** @var MockObject|SwooleResponse $swooleResponse */
53
- $ swooleResponse = $ this ->getMockByCalls (SwooleResponse::class, [
54
- Call::create ('status ' )->with (200 , 'OK ' )->willReturn (true ),
55
- Call::create ('header ' )->with ('Content-Type ' , 'application/json ' , true )->willReturn (true ),
56
- Call::create ('cookie ' )
57
- ->with (
58
- 'id ' ,
59
- 'a3fWa ' ,
60
- 1_445_412_480 ,
61
- '/some/path ' ,
62
- 'some-domain.org ' ,
63
- true ,
64
- true ,
65
- 'Strict ' ,
66
- ''
67
- )
68
- ->willReturn (true ),
69
- Call::create ('write ' )->with ('This is the body. ' )->willReturn (true ),
70
- Call::create ('end ' )->with (null )->willReturn (true ),
71
- ]);
52
+ $ installedVersion = phpversion ('swoole ' );
53
+
54
+ if (version_compare ($ installedVersion , '6.0.0-RC1 ' , '>= ' )) {
55
+ /** @var MockObject|SwooleResponse $swooleResponse */
56
+ $ swooleResponse = $ this ->getMockByCalls (SwooleResponse::class, [
57
+ Call::create ('status ' )->with (200 , 'OK ' )->willReturn (true ),
58
+ Call::create ('header ' )->with ('Content-Type ' , 'application/json ' , true )->willReturn (true ),
59
+ Call::create ('cookie ' )
60
+ ->with (
61
+ 'id ' ,
62
+ 'a3fWa ' ,
63
+ 1_445_412_480 ,
64
+ '/some/path ' ,
65
+ 'some-domain.org ' ,
66
+ true ,
67
+ true ,
68
+ 'Strict ' ,
69
+ '' ,
70
+ false
71
+ )
72
+ ->willReturn (true ),
73
+ Call::create ('write ' )->with ('This is the body. ' )->willReturn (true ),
74
+ Call::create ('end ' )->with (null )->willReturn (true ),
75
+ ]);
76
+ } else {
77
+ /** @var MockObject|SwooleResponse $swooleResponse */
78
+ $ swooleResponse = $ this ->getMockByCalls (SwooleResponse::class, [
79
+ Call::create ('status ' )->with (200 , 'OK ' )->willReturn (true ),
80
+ Call::create ('header ' )->with ('Content-Type ' , 'application/json ' , true )->willReturn (true ),
81
+ Call::create ('cookie ' )
82
+ ->with (
83
+ 'id ' ,
84
+ 'a3fWa ' ,
85
+ 1_445_412_480 ,
86
+ '/some/path ' ,
87
+ 'some-domain.org ' ,
88
+ true ,
89
+ true ,
90
+ 'Strict ' ,
91
+ '' ,
92
+ )
93
+ ->willReturn (true ),
94
+ Call::create ('write ' )->with ('This is the body. ' )->willReturn (true ),
95
+ Call::create ('end ' )->with (null )->willReturn (true ),
96
+ ]);
97
+ }
72
98
73
99
$ swooleResponseEmitter = new SwooleResponseEmitter ();
74
100
$ swooleResponseEmitter ->emit ($ response , $ swooleResponse );
@@ -101,24 +127,48 @@ public function testInvokeWithEmptyBody(): void
101
127
Call::create ('getBody ' )->with ()->willReturn ($ responseBody ),
102
128
]);
103
129
104
- /** @var MockObject|SwooleResponse $swooleResponse */
105
- $ swooleResponse = $ this ->getMockByCalls (SwooleResponse::class, [
106
- Call::create ('status ' )->with (200 , 'OK ' )->willReturn (true ),
107
- Call::create ('header ' )->with ('Content-Type ' , 'application/json ' , true )->willReturn (true ),
108
- Call::create ('cookie ' )
109
- ->with (
110
- 'id ' ,
111
- 'a3fWa ' ,
112
- 1_445_412_480 ,
113
- '/ ' ,
114
- '' ,
115
- true ,
116
- true ,
117
- '' ,
118
- ''
119
- )->willReturn (true ),
120
- Call::create ('end ' )->with (null )->willReturn (true ),
121
- ]);
130
+ $ installedVersion = phpversion ('swoole ' );
131
+
132
+ if (version_compare ($ installedVersion , '6.0.0-RC1 ' , '>= ' )) {
133
+ /** @var MockObject|SwooleResponse $swooleResponse */
134
+ $ swooleResponse = $ this ->getMockByCalls (SwooleResponse::class, [
135
+ Call::create ('status ' )->with (200 , 'OK ' )->willReturn (true ),
136
+ Call::create ('header ' )->with ('Content-Type ' , 'application/json ' , true )->willReturn (true ),
137
+ Call::create ('cookie ' )
138
+ ->with (
139
+ 'id ' ,
140
+ 'a3fWa ' ,
141
+ 1_445_412_480 ,
142
+ '/ ' ,
143
+ '' ,
144
+ true ,
145
+ true ,
146
+ '' ,
147
+ '' ,
148
+ false ,
149
+ )->willReturn (true ),
150
+ Call::create ('end ' )->with (null )->willReturn (true ),
151
+ ]);
152
+ } else {
153
+ /** @var MockObject|SwooleResponse $swooleResponse */
154
+ $ swooleResponse = $ this ->getMockByCalls (SwooleResponse::class, [
155
+ Call::create ('status ' )->with (200 , 'OK ' )->willReturn (true ),
156
+ Call::create ('header ' )->with ('Content-Type ' , 'application/json ' , true )->willReturn (true ),
157
+ Call::create ('cookie ' )
158
+ ->with (
159
+ 'id ' ,
160
+ 'a3fWa ' ,
161
+ 1_445_412_480 ,
162
+ '/ ' ,
163
+ '' ,
164
+ true ,
165
+ true ,
166
+ '' ,
167
+ '' ,
168
+ )->willReturn (true ),
169
+ Call::create ('end ' )->with (null )->willReturn (true ),
170
+ ]);
171
+ }
122
172
123
173
$ swooleResponseEmitter = new SwooleResponseEmitter ();
124
174
$ swooleResponseEmitter ->emit ($ response , $ swooleResponse );
0 commit comments