Skip to content

Commit 1f09166

Browse files
committed
rewrite tests from phpspec to phpunit
1 parent 0cfe985 commit 1f09166

File tree

70 files changed

+2689
-3047
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2689
-3047
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
name: PHP ${{ matrix.php }} Latest
1212
runs-on: ubuntu-latest
1313
strategy:
14+
fail-fast: false
1415
matrix:
1516
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
1617

@@ -39,6 +40,7 @@ jobs:
3940
name: PHP ${{ matrix.php }} Lowest
4041
runs-on: ubuntu-latest
4142
strategy:
43+
fail-fast: false
4244
matrix:
4345
php: ['7.1', '7.4', '8.2', '8.3']
4446

@@ -113,7 +115,6 @@ jobs:
113115

114116
- name: Install dependencies
115117
run: |
116-
composer require "friends-of-phpspec/phpspec-code-coverage:^4.3.2" --no-interaction --no-update
117118
composer update --prefer-dist --no-interaction --no-progress
118119
119120
- name: Execute tests

composer.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
"doctrine/instantiator": "^1.1",
2525
"guzzlehttp/psr7": "^1.4",
2626
"nyholm/psr7": "^1.2",
27-
"phpspec/phpspec": "^5.1 || ^6.3 || ^7.1",
28-
"phpspec/prophecy": "^1.10.2",
2927
"phpunit/phpunit": "^7.5.20 || ^8.5.33 || ^9.6.7"
3028
},
3129
"suggest": {
@@ -42,17 +40,14 @@
4240
},
4341
"autoload-dev": {
4442
"psr-4": {
45-
"spec\\Http\\Client\\Common\\": "spec/",
4643
"Tests\\Http\\Client\\Common\\": "tests/"
4744
}
4845
},
4946
"scripts": {
5047
"test": [
51-
"vendor/bin/phpspec run",
5248
"vendor/bin/phpunit"
5349
],
5450
"test-ci": [
55-
"vendor/bin/phpspec run -c phpspec.ci.yml",
5651
"vendor/bin/phpunit"
5752
]
5853
},

phpstan.neon.dist

Lines changed: 279 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
parameters:
22
level: max
3-
checkMissingIterableValueType: false
43
treatPhpDocTypesAsCertain: false
54
paths:
65
- src
76
ignoreErrors:
7+
- "#.*no value type specified in iterable type array.*#"
88
# Exception still thrown in PHP 8, not sure why phpstan complains
99
-
1010
message: "#^Dead catch - UnexpectedValueException is never thrown in the try block\\.$#"
@@ -60,15 +60,13 @@ parameters:
6060
# phpstan is confused by the optional dependencies. we check for existence first
6161
-
6262
message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\RedirectPlugin::guessStreamFactory\\(\\) should return Psr\\\\Http\\\\Message\\\\StreamFactoryInterface\\|null but returns Nyholm\\\\Psr7\\\\Factory\\\\Psr17Factory\\.$#"
63-
count: 1
64-
path: src/Plugin/RedirectPlugin.php
65-
6663
# phpstan is confused by the optional dependencies. we check for existence first
6764
-
6865
message: "#^Call to static method streamFor\\(\\) on an unknown class GuzzleHttp\\\\Psr7\\\\Utils\\.$#"
66+
-
67+
message: "#^Method Http\\\\Client\\\\Common\\\\PluginClient\\:\\:sendRequest\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#"
6968
count: 1
7069
path: src/Plugin/RedirectPlugin.php
71-
7270
-
7371
message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\RetryPlugin\\:\\:retry\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#"
7472
count: 1
@@ -78,3 +76,279 @@ parameters:
7876
message: "#^Method Http\\\\Client\\\\Common\\\\PluginClient\\:\\:sendRequest\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#"
7977
count: 2
8078
path: src/PluginClient.php
79+
80+
-
81+
message: '#^Method Http\\Client\\Common\\BatchResult\:\:getExceptionFor\(\) has UnexpectedValueException in PHPDoc @throws tag but it''s not thrown\.$#'
82+
identifier: throws.unusedType
83+
count: 1
84+
path: src/BatchResult.php
85+
86+
-
87+
message: '#^Method Http\\Client\\Common\\BatchResult\:\:getResponseFor\(\) has UnexpectedValueException in PHPDoc @throws tag but it''s not thrown\.$#'
88+
identifier: throws.unusedType
89+
count: 1
90+
path: src/BatchResult.php
91+
92+
-
93+
message: '#^Parameter \#1 \$response of method Http\\Client\\Common\\Deferred\:\:resolve\(\) expects Psr\\Http\\Message\\ResponseInterface, mixed given\.$#'
94+
identifier: argument.type
95+
count: 2
96+
path: src/Deferred.php
97+
98+
-
99+
message: '#^Invalid type mixed to throw\.$#'
100+
identifier: throw.notThrowable
101+
count: 1
102+
path: src/HttpClientPool/HttpClientPoolItem.php
103+
104+
-
105+
message: '#^Method Http\\Client\\Common\\HttpMethodsClient\:\:createRequest\(\) should return Psr\\Http\\Message\\RequestInterface but returns mixed\.$#'
106+
identifier: return.type
107+
count: 1
108+
path: src/HttpMethodsClient.php
109+
110+
-
111+
message: '#^Parameter \#2 \$value of method Psr\\Http\\Message\\MessageInterface\:\:withHeader\(\) expects array\<string\>\|string, mixed given\.$#'
112+
identifier: argument.type
113+
count: 1
114+
path: src/HttpMethodsClient.php
115+
116+
-
117+
message: '#^Property Http\\Client\\Common\\Plugin\\AddHostPlugin\:\:\$replace \(bool\) does not accept mixed\.$#'
118+
identifier: assign.propertyType
119+
count: 1
120+
path: src/Plugin/AddHostPlugin.php
121+
122+
-
123+
message: '#^Parameter \#2 \$config of class Http\\Client\\Common\\Plugin\\AddHostPlugin constructor expects array\{replace\?\: bool\}, array given\.$#'
124+
identifier: argument.type
125+
count: 1
126+
path: src/Plugin/BaseUriPlugin.php
127+
128+
-
129+
message: '#^Property Http\\Client\\Common\\Plugin\\ContentTypePlugin\:\:\$sizeLimit \(int\) does not accept mixed\.$#'
130+
identifier: assign.propertyType
131+
count: 1
132+
path: src/Plugin/ContentTypePlugin.php
133+
134+
-
135+
message: '#^Property Http\\Client\\Common\\Plugin\\ContentTypePlugin\:\:\$skipDetection \(bool\) does not accept mixed\.$#'
136+
identifier: assign.propertyType
137+
count: 1
138+
path: src/Plugin/ContentTypePlugin.php
139+
140+
-
141+
message: '#^Property Http\\Client\\Common\\Plugin\\DecoderPlugin\:\:\$useContentEncoding \(bool\) does not accept mixed\.$#'
142+
identifier: assign.propertyType
143+
count: 1
144+
path: src/Plugin/DecoderPlugin.php
145+
146+
-
147+
message: '#^Property Http\\Client\\Common\\Plugin\\ErrorPlugin\:\:\$onlyServerException \(bool\) does not accept mixed\.$#'
148+
identifier: assign.propertyType
149+
count: 1
150+
path: src/Plugin/ErrorPlugin.php
151+
152+
-
153+
message: '#^Parameter \#2 \$value of method Psr\\Http\\Message\\MessageInterface\:\:withAddedHeader\(\) expects array\<string\>\|string, mixed given\.$#'
154+
identifier: argument.type
155+
count: 1
156+
path: src/Plugin/HeaderAppendPlugin.php
157+
158+
-
159+
message: '#^Parameter \#2 \$value of method Psr\\Http\\Message\\MessageInterface\:\:withHeader\(\) expects array\<string\>\|string, mixed given\.$#'
160+
identifier: argument.type
161+
count: 1
162+
path: src/Plugin/HeaderDefaultsPlugin.php
163+
164+
-
165+
message: '#^Parameter \#1 \$name of method Psr\\Http\\Message\\MessageInterface\:\:hasHeader\(\) expects string, mixed given\.$#'
166+
identifier: argument.type
167+
count: 1
168+
path: src/Plugin/HeaderRemovePlugin.php
169+
170+
-
171+
message: '#^Parameter \#1 \$name of method Psr\\Http\\Message\\MessageInterface\:\:withoutHeader\(\) expects string, mixed given\.$#'
172+
identifier: argument.type
173+
count: 1
174+
path: src/Plugin/HeaderRemovePlugin.php
175+
176+
-
177+
message: '#^Parameter \#2 \$value of method Psr\\Http\\Message\\MessageInterface\:\:withHeader\(\) expects array\<string\>\|string, mixed given\.$#'
178+
identifier: argument.type
179+
count: 1
180+
path: src/Plugin/HeaderSetPlugin.php
181+
182+
-
183+
message: '#^Cannot access offset ''multiple'' on mixed\.$#'
184+
identifier: offsetAccess.nonOffsetAccessible
185+
count: 1
186+
path: src/Plugin/RedirectPlugin.php
187+
188+
-
189+
message: '#^Cannot access offset ''permanent'' on mixed\.$#'
190+
identifier: offsetAccess.nonOffsetAccessible
191+
count: 1
192+
path: src/Plugin/RedirectPlugin.php
193+
194+
-
195+
message: '#^Cannot access offset ''status'' on mixed\.$#'
196+
identifier: offsetAccess.nonOffsetAccessible
197+
count: 1
198+
path: src/Plugin/RedirectPlugin.php
199+
200+
-
201+
message: '#^Cannot access offset ''switch'' on mixed\.$#'
202+
identifier: offsetAccess.nonOffsetAccessible
203+
count: 4
204+
path: src/Plugin/RedirectPlugin.php
205+
206+
-
207+
message: '#^Cannot access offset ''to'' on mixed\.$#'
208+
identifier: offsetAccess.nonOffsetAccessible
209+
count: 2
210+
path: src/Plugin/RedirectPlugin.php
211+
212+
-
213+
message: '#^Cannot access offset ''unless'' on mixed\.$#'
214+
identifier: offsetAccess.nonOffsetAccessible
215+
count: 1
216+
path: src/Plugin/RedirectPlugin.php
217+
218+
-
219+
message: '#^Cannot access offset ''uri'' on mixed\.$#'
220+
identifier: offsetAccess.nonOffsetAccessible
221+
count: 1
222+
path: src/Plugin/RedirectPlugin.php
223+
224+
-
225+
message: '#^Method Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:guessStreamFactory\(\) should return Psr\\Http\\Message\\StreamFactoryInterface\|null but returns mixed\.$#'
226+
identifier: return.type
227+
count: 1
228+
path: src/Plugin/RedirectPlugin.php
229+
230+
-
231+
message: '#^Parameter \#1 \$method of method Psr\\Http\\Message\\RequestInterface\:\:withMethod\(\) expects string, mixed given\.$#'
232+
identifier: argument.type
233+
count: 1
234+
path: src/Plugin/RedirectPlugin.php
235+
236+
-
237+
message: '#^Parameter \#2 \$haystack of function in_array expects array, mixed given\.$#'
238+
identifier: argument.type
239+
count: 1
240+
path: src/Plugin/RedirectPlugin.php
241+
242+
-
243+
message: '#^Parameter \#2 \$targetUri of method Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:buildRedirectRequest\(\) expects Psr\\Http\\Message\\UriInterface, mixed given\.$#'
244+
identifier: argument.type
245+
count: 1
246+
path: src/Plugin/RedirectPlugin.php
247+
248+
-
249+
message: '#^Parameter \#3 \$statusCode of method Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:buildRedirectRequest\(\) expects int, mixed given\.$#'
250+
identifier: argument.type
251+
count: 1
252+
path: src/Plugin/RedirectPlugin.php
253+
254+
-
255+
message: '#^Property Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:\$preserveHeader \(array\|bool\) does not accept mixed\.$#'
256+
identifier: assign.propertyType
257+
count: 1
258+
path: src/Plugin/RedirectPlugin.php
259+
260+
-
261+
message: '#^Property Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:\$streamFactory \(Psr\\Http\\Message\\StreamFactoryInterface\|null\) does not accept mixed\.$#'
262+
identifier: assign.propertyType
263+
count: 1
264+
path: src/Plugin/RedirectPlugin.php
265+
266+
-
267+
message: '#^Property Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:\$useDefaultForMultiple \(bool\) does not accept mixed\.$#'
268+
identifier: assign.propertyType
269+
count: 1
270+
path: src/Plugin/RedirectPlugin.php
271+
272+
-
273+
message: '#^Cannot use \+\+ on mixed\.$#'
274+
identifier: preInc.type
275+
count: 1
276+
path: src/Plugin/RetryPlugin.php
277+
278+
-
279+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$errorResponseDecider \(callable\(\)\: mixed\) does not accept mixed\.$#'
280+
identifier: assign.propertyType
281+
count: 1
282+
path: src/Plugin/RetryPlugin.php
283+
284+
-
285+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$errorResponseDelay \(callable\(\)\: mixed\) does not accept mixed\.$#'
286+
identifier: assign.propertyType
287+
count: 1
288+
path: src/Plugin/RetryPlugin.php
289+
290+
-
291+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$exceptionDecider \(callable\(\)\: mixed\) does not accept mixed\.$#'
292+
identifier: assign.propertyType
293+
count: 1
294+
path: src/Plugin/RetryPlugin.php
295+
296+
-
297+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$exceptionDelay \(callable\(\)\: mixed\) does not accept mixed\.$#'
298+
identifier: assign.propertyType
299+
count: 1
300+
path: src/Plugin/RetryPlugin.php
301+
302+
-
303+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$retry \(int\) does not accept mixed\.$#'
304+
identifier: assign.propertyType
305+
count: 1
306+
path: src/Plugin/RetryPlugin.php
307+
308+
-
309+
message: '#^Property Http\\Client\\Common\\Plugin\\SeekableBodyPlugin\:\:\$memoryBufferSize \(int\) does not accept mixed\.$#'
310+
identifier: assign.propertyType
311+
count: 1
312+
path: src/Plugin/SeekableBodyPlugin.php
313+
314+
-
315+
message: '#^Property Http\\Client\\Common\\Plugin\\SeekableBodyPlugin\:\:\$useFileBuffer \(bool\) does not accept mixed\.$#'
316+
identifier: assign.propertyType
317+
count: 1
318+
path: src/Plugin/SeekableBodyPlugin.php
319+
320+
-
321+
message: '#^Trait Http\\Client\\Common\\Plugin\\VersionBridgePlugin is used zero times and is not analysed\.$#'
322+
identifier: trait.unused
323+
count: 1
324+
path: src/Plugin/VersionBridgePlugin.php
325+
326+
-
327+
message: '#^Method Http\\Client\\Common\\PluginChain\:\:__invoke\(\) should return Http\\Promise\\Promise but returns mixed\.$#'
328+
identifier: return.type
329+
count: 1
330+
path: src/PluginChain.php
331+
332+
-
333+
message: '#^Parameter \#1 \$response of class Http\\Client\\Promise\\HttpFulfilledPromise constructor expects Psr\\Http\\Message\\ResponseInterface, mixed given\.$#'
334+
identifier: argument.type
335+
count: 1
336+
path: src/PluginClient.php
337+
338+
-
339+
message: '#^Parameter \#3 \$options of class Http\\Client\\Common\\PluginChain constructor expects array\{max_restarts\?\: int\}, array given\.$#'
340+
identifier: argument.type
341+
count: 1
342+
path: src/PluginClient.php
343+
344+
-
345+
message: '#^Parameter \#3 \$options of class Http\\Client\\Common\\PluginClient constructor expects array\{max_restarts\?\: int\}, array given\.$#'
346+
identifier: argument.type
347+
count: 1
348+
path: src/PluginClientBuilder.php
349+
350+
-
351+
message: '#^Trait Http\\Client\\Common\\VersionBridgeClient is used zero times and is not analysed\.$#'
352+
identifier: trait.unused
353+
count: 1
354+
path: src/VersionBridgeClient.php

spec/BatchClientSpec.php

Lines changed: 0 additions & 36 deletions
This file was deleted.

0 commit comments

Comments
 (0)