1010
1111abstract class HttpBaseTest extends TestCase
1212{
13- use PhpUnitBackwardCompatibleTrait;
14-
1513 /**
1614 * @var string
1715 */
@@ -36,7 +34,7 @@ abstract class HttpBaseTest extends TestCase
3634 /**
3735 * @var array
3836 */
39- protected $ defaultHeaders = [
37+ protected static $ defaultHeaders = [
4038 'Connection ' => 'close ' ,
4139 'User-Agent ' => 'PHP HTTP Adapter ' ,
4240 'Content-Length ' => '0 ' ,
@@ -61,13 +59,13 @@ public static function tearDownAfterClass(): void
6159 }
6260 }
6361
64- public function requestProvider (): array
62+ public static function requestProvider (): array
6563 {
6664 $ sets = [
67- 'methods ' => $ this -> getMethods (),
68- 'uris ' => [$ this -> getUri ()],
69- 'headers ' => $ this -> getHeaders (),
70- 'body ' => $ this -> getBodies (),
65+ 'methods ' => self :: getMethods (),
66+ 'uris ' => [self :: getUri ()],
67+ 'headers ' => self :: getHeaders (),
68+ 'body ' => self :: getBodies (),
7169 ];
7270
7371 $ cartesianProduct = new CartesianProduct ($ sets );
@@ -84,21 +82,21 @@ public function requestProvider(): array
8482 });
8583 }
8684
87- public function requestWithOutcomeProvider (): array
85+ public static function requestWithOutcomeProvider (): array
8886 {
8987 $ sets = [
90- 'urisAndOutcomes ' => $ this -> getUrisAndOutcomes (),
91- 'protocolVersions ' => $ this -> getProtocolVersions (),
92- 'headers ' => $ this -> getHeaders (),
93- 'body ' => $ this -> getBodies (),
88+ 'urisAndOutcomes ' => self :: getUrisAndOutcomes (),
89+ 'protocolVersions ' => self :: getProtocolVersions (),
90+ 'headers ' => self :: getHeaders (),
91+ 'body ' => self :: getBodies (),
9492 ];
9593
9694 $ cartesianProduct = new CartesianProduct ($ sets );
9795
9896 return $ cartesianProduct ->compute ();
9997 }
10098
101- private function getMethods (): array
99+ private static function getMethods (): array
102100 {
103101 return [
104102 'GET ' ,
@@ -116,7 +114,7 @@ private function getMethods(): array
116114 *
117115 * @return string|null
118116 */
119- protected function getUri (array $ query = [])
117+ protected static function getUri (array $ query = [])
120118 {
121119 return !empty ($ query )
122120 ? PHPUnitUtility::getUri ().'? ' .http_build_query ($ query , '' , '& ' )
@@ -134,25 +132,25 @@ protected function getInvalidUri()
134132 /**
135133 * @return array
136134 */
137- private function getUrisAndOutcomes ()
135+ private static function getUrisAndOutcomes ()
138136 {
139137 return [
140138 [
141- $ this -> getUri (['client_error ' => true ]),
139+ self :: getUri (['client_error ' => true ]),
142140 [
143141 'statusCode ' => 400 ,
144142 'reasonPhrase ' => 'Bad Request ' ,
145143 ],
146144 ],
147145 [
148- $ this -> getUri (['server_error ' => true ]),
146+ self :: getUri (['server_error ' => true ]),
149147 [
150148 'statusCode ' => 500 ,
151149 'reasonPhrase ' => 'Internal Server Error ' ,
152150 ],
153151 ],
154152 [
155- $ this -> getUri (['redirect ' => true ]),
153+ self :: getUri (['redirect ' => true ]),
156154 [
157155 'statusCode ' => 302 ,
158156 'reasonPhrase ' => 'Found ' ,
@@ -165,41 +163,41 @@ private function getUrisAndOutcomes()
165163 /**
166164 * @return array
167165 */
168- private function getProtocolVersions ()
166+ private static function getProtocolVersions ()
169167 {
170168 return ['1.1 ' , '1.0 ' ];
171169 }
172170
173171 /**
174172 * @return string[]
175173 */
176- private function getHeaders ()
174+ private static function getHeaders ()
177175 {
178- $ headers = $ this -> defaultHeaders ;
176+ $ headers = self :: $ defaultHeaders ;
179177 $ headers ['Accept-Charset ' ] = 'utf-8 ' ;
180178 $ headers ['Accept-Language ' ] = 'en ' ;
181179
182180 return [
183- $ this -> defaultHeaders ,
181+ self :: $ defaultHeaders ,
184182 $ headers ,
185183 ];
186184 }
187185
188186 /**
189187 * @return array
190188 */
191- private function getBodies ()
189+ private static function getBodies ()
192190 {
193191 return [
194192 null ,
195- http_build_query ($ this -> getData (), '' , '& ' ),
193+ http_build_query (self :: getData (), '' , '& ' ),
196194 ];
197195 }
198196
199197 /**
200198 * @return array
201199 */
202- private function getData ()
200+ private static function getData ()
203201 {
204202 return ['param1 ' => 'foo ' , 'param2 ' => ['bar ' , ['baz ' ]]];
205203 }
@@ -223,7 +221,7 @@ protected function assertResponse(ResponseInterface $response, array $options =
223221 if (null === $ options ['body ' ]) {
224222 $ this ->assertEmpty ($ response ->getBody ()->__toString ());
225223 } else {
226- $ this -> assertStringContainsString ($ options ['body ' ], $ response ->getBody ()->__toString ());
224+ self :: assertStringContainsString ($ options ['body ' ], $ response ->getBody ()->__toString ());
227225 }
228226 }
229227
0 commit comments