Skip to content

Commit 07a61d6

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

File tree

70 files changed

+2682
-3049
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

+2682
-3049
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: 272 additions & 7 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\\.$#"
@@ -59,22 +59,287 @@ parameters:
5959

6060
# phpstan is confused by the optional dependencies. we check for existence first
6161
-
62-
message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\RedirectPlugin::guessStreamFactory\\(\\) should return Psr\\\\Http\\\\Message\\\\StreamFactoryInterface\\|null but returns Nyholm\\\\Psr7\\\\Factory\\\\Psr17Factory\\.$#"
62+
message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\RetryPlugin\\:\\:retry\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#"
63+
count: 1
64+
path: src/Plugin/RetryPlugin.php
65+
66+
-
67+
message: "#^Method Http\\\\Client\\\\Common\\\\PluginClient\\:\\:sendRequest\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#"
68+
count: 2
69+
path: src/PluginClient.php
70+
71+
-
72+
message: '#^Method Http\\Client\\Common\\BatchResult\:\:getExceptionFor\(\) has UnexpectedValueException in PHPDoc @throws tag but it''s not thrown\.$#'
73+
identifier: throws.unusedType
74+
count: 1
75+
path: src/BatchResult.php
76+
77+
-
78+
message: '#^Method Http\\Client\\Common\\BatchResult\:\:getResponseFor\(\) has UnexpectedValueException in PHPDoc @throws tag but it''s not thrown\.$#'
79+
identifier: throws.unusedType
80+
count: 1
81+
path: src/BatchResult.php
82+
83+
-
84+
message: '#^Parameter \#1 \$response of method Http\\Client\\Common\\Deferred\:\:resolve\(\) expects Psr\\Http\\Message\\ResponseInterface, mixed given\.$#'
85+
identifier: argument.type
86+
count: 2
87+
path: src/Deferred.php
88+
89+
-
90+
message: '#^Invalid type mixed to throw\.$#'
91+
identifier: throw.notThrowable
92+
count: 1
93+
path: src/HttpClientPool/HttpClientPoolItem.php
94+
95+
-
96+
message: '#^Method Http\\Client\\Common\\HttpMethodsClient\:\:createRequest\(\) should return Psr\\Http\\Message\\RequestInterface but returns mixed\.$#'
97+
identifier: return.type
98+
count: 1
99+
path: src/HttpMethodsClient.php
100+
101+
-
102+
message: '#^Parameter \#2 \$value of method Psr\\Http\\Message\\MessageInterface\:\:withHeader\(\) expects array\<string\>\|string, mixed given\.$#'
103+
identifier: argument.type
104+
count: 1
105+
path: src/HttpMethodsClient.php
106+
107+
-
108+
message: '#^Property Http\\Client\\Common\\Plugin\\AddHostPlugin\:\:\$replace \(bool\) does not accept mixed\.$#'
109+
identifier: assign.propertyType
110+
count: 1
111+
path: src/Plugin/AddHostPlugin.php
112+
113+
-
114+
message: '#^Parameter \#2 \$config of class Http\\Client\\Common\\Plugin\\AddHostPlugin constructor expects array\{replace\?\: bool\}, array given\.$#'
115+
identifier: argument.type
116+
count: 1
117+
path: src/Plugin/BaseUriPlugin.php
118+
119+
-
120+
message: '#^Property Http\\Client\\Common\\Plugin\\ContentTypePlugin\:\:\$sizeLimit \(int\) does not accept mixed\.$#'
121+
identifier: assign.propertyType
122+
count: 1
123+
path: src/Plugin/ContentTypePlugin.php
124+
125+
-
126+
message: '#^Property Http\\Client\\Common\\Plugin\\ContentTypePlugin\:\:\$skipDetection \(bool\) does not accept mixed\.$#'
127+
identifier: assign.propertyType
128+
count: 1
129+
path: src/Plugin/ContentTypePlugin.php
130+
131+
-
132+
message: '#^Property Http\\Client\\Common\\Plugin\\DecoderPlugin\:\:\$useContentEncoding \(bool\) does not accept mixed\.$#'
133+
identifier: assign.propertyType
134+
count: 1
135+
path: src/Plugin/DecoderPlugin.php
136+
137+
-
138+
message: '#^Property Http\\Client\\Common\\Plugin\\ErrorPlugin\:\:\$onlyServerException \(bool\) does not accept mixed\.$#'
139+
identifier: assign.propertyType
140+
count: 1
141+
path: src/Plugin/ErrorPlugin.php
142+
143+
-
144+
message: '#^Parameter \#2 \$value of method Psr\\Http\\Message\\MessageInterface\:\:withAddedHeader\(\) expects array\<string\>\|string, mixed given\.$#'
145+
identifier: argument.type
146+
count: 1
147+
path: src/Plugin/HeaderAppendPlugin.php
148+
149+
-
150+
message: '#^Parameter \#2 \$value of method Psr\\Http\\Message\\MessageInterface\:\:withHeader\(\) expects array\<string\>\|string, mixed given\.$#'
151+
identifier: argument.type
152+
count: 1
153+
path: src/Plugin/HeaderDefaultsPlugin.php
154+
155+
-
156+
message: '#^Parameter \#1 \$name of method Psr\\Http\\Message\\MessageInterface\:\:hasHeader\(\) expects string, mixed given\.$#'
157+
identifier: argument.type
158+
count: 1
159+
path: src/Plugin/HeaderRemovePlugin.php
160+
161+
-
162+
message: '#^Parameter \#1 \$name of method Psr\\Http\\Message\\MessageInterface\:\:withoutHeader\(\) expects string, mixed given\.$#'
163+
identifier: argument.type
164+
count: 1
165+
path: src/Plugin/HeaderRemovePlugin.php
166+
167+
-
168+
message: '#^Parameter \#2 \$value of method Psr\\Http\\Message\\MessageInterface\:\:withHeader\(\) expects array\<string\>\|string, mixed given\.$#'
169+
identifier: argument.type
170+
count: 1
171+
path: src/Plugin/HeaderSetPlugin.php
172+
173+
-
174+
message: '#^Cannot access offset ''multiple'' on mixed\.$#'
175+
identifier: offsetAccess.nonOffsetAccessible
63176
count: 1
64177
path: src/Plugin/RedirectPlugin.php
65178

66-
# phpstan is confused by the optional dependencies. we check for existence first
67179
-
68-
message: "#^Call to static method streamFor\\(\\) on an unknown class GuzzleHttp\\\\Psr7\\\\Utils\\.$#"
180+
message: '#^Cannot access offset ''permanent'' on mixed\.$#'
181+
identifier: offsetAccess.nonOffsetAccessible
69182
count: 1
70183
path: src/Plugin/RedirectPlugin.php
71184

72185
-
73-
message: "#^Method Http\\\\Client\\\\Common\\\\Plugin\\\\RetryPlugin\\:\\:retry\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#"
186+
message: '#^Cannot access offset ''status'' on mixed\.$#'
187+
identifier: offsetAccess.nonOffsetAccessible
74188
count: 1
75-
path: src/Plugin/RetryPlugin.php
189+
path: src/Plugin/RedirectPlugin.php
76190

77191
-
78-
message: "#^Method Http\\\\Client\\\\Common\\\\PluginClient\\:\\:sendRequest\\(\\) should return Psr\\\\Http\\\\Message\\\\ResponseInterface but returns mixed\\.$#"
192+
message: '#^Cannot access offset ''switch'' on mixed\.$#'
193+
identifier: offsetAccess.nonOffsetAccessible
194+
count: 4
195+
path: src/Plugin/RedirectPlugin.php
196+
197+
-
198+
message: '#^Cannot access offset ''to'' on mixed\.$#'
199+
identifier: offsetAccess.nonOffsetAccessible
79200
count: 2
201+
path: src/Plugin/RedirectPlugin.php
202+
203+
-
204+
message: '#^Cannot access offset ''unless'' on mixed\.$#'
205+
identifier: offsetAccess.nonOffsetAccessible
206+
count: 1
207+
path: src/Plugin/RedirectPlugin.php
208+
209+
-
210+
message: '#^Cannot access offset ''uri'' on mixed\.$#'
211+
identifier: offsetAccess.nonOffsetAccessible
212+
count: 1
213+
path: src/Plugin/RedirectPlugin.php
214+
215+
-
216+
message: '#^Method Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:guessStreamFactory\(\) should return Psr\\Http\\Message\\StreamFactoryInterface\|null but returns mixed\.$#'
217+
identifier: return.type
218+
count: 1
219+
path: src/Plugin/RedirectPlugin.php
220+
221+
-
222+
message: '#^Parameter \#1 \$method of method Psr\\Http\\Message\\RequestInterface\:\:withMethod\(\) expects string, mixed given\.$#'
223+
identifier: argument.type
224+
count: 1
225+
path: src/Plugin/RedirectPlugin.php
226+
227+
-
228+
message: '#^Parameter \#2 \$haystack of function in_array expects array, mixed given\.$#'
229+
identifier: argument.type
230+
count: 1
231+
path: src/Plugin/RedirectPlugin.php
232+
233+
-
234+
message: '#^Parameter \#2 \$targetUri of method Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:buildRedirectRequest\(\) expects Psr\\Http\\Message\\UriInterface, mixed given\.$#'
235+
identifier: argument.type
236+
count: 1
237+
path: src/Plugin/RedirectPlugin.php
238+
239+
-
240+
message: '#^Parameter \#3 \$statusCode of method Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:buildRedirectRequest\(\) expects int, mixed given\.$#'
241+
identifier: argument.type
242+
count: 1
243+
path: src/Plugin/RedirectPlugin.php
244+
245+
-
246+
message: '#^Property Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:\$preserveHeader \(array\|bool\) does not accept mixed\.$#'
247+
identifier: assign.propertyType
248+
count: 1
249+
path: src/Plugin/RedirectPlugin.php
250+
251+
-
252+
message: '#^Property Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:\$streamFactory \(Psr\\Http\\Message\\StreamFactoryInterface\|null\) does not accept mixed\.$#'
253+
identifier: assign.propertyType
254+
count: 1
255+
path: src/Plugin/RedirectPlugin.php
256+
257+
-
258+
message: '#^Property Http\\Client\\Common\\Plugin\\RedirectPlugin\:\:\$useDefaultForMultiple \(bool\) does not accept mixed\.$#'
259+
identifier: assign.propertyType
260+
count: 1
261+
path: src/Plugin/RedirectPlugin.php
262+
263+
-
264+
message: '#^Cannot use \+\+ on mixed\.$#'
265+
identifier: preInc.type
266+
count: 1
267+
path: src/Plugin/RetryPlugin.php
268+
269+
-
270+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$errorResponseDecider \(callable\(\)\: mixed\) does not accept mixed\.$#'
271+
identifier: assign.propertyType
272+
count: 1
273+
path: src/Plugin/RetryPlugin.php
274+
275+
-
276+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$errorResponseDelay \(callable\(\)\: mixed\) does not accept mixed\.$#'
277+
identifier: assign.propertyType
278+
count: 1
279+
path: src/Plugin/RetryPlugin.php
280+
281+
-
282+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$exceptionDecider \(callable\(\)\: mixed\) does not accept mixed\.$#'
283+
identifier: assign.propertyType
284+
count: 1
285+
path: src/Plugin/RetryPlugin.php
286+
287+
-
288+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$exceptionDelay \(callable\(\)\: mixed\) does not accept mixed\.$#'
289+
identifier: assign.propertyType
290+
count: 1
291+
path: src/Plugin/RetryPlugin.php
292+
293+
-
294+
message: '#^Property Http\\Client\\Common\\Plugin\\RetryPlugin\:\:\$retry \(int\) does not accept mixed\.$#'
295+
identifier: assign.propertyType
296+
count: 1
297+
path: src/Plugin/RetryPlugin.php
298+
299+
-
300+
message: '#^Property Http\\Client\\Common\\Plugin\\SeekableBodyPlugin\:\:\$memoryBufferSize \(int\) does not accept mixed\.$#'
301+
identifier: assign.propertyType
302+
count: 1
303+
path: src/Plugin/SeekableBodyPlugin.php
304+
305+
-
306+
message: '#^Property Http\\Client\\Common\\Plugin\\SeekableBodyPlugin\:\:\$useFileBuffer \(bool\) does not accept mixed\.$#'
307+
identifier: assign.propertyType
308+
count: 1
309+
path: src/Plugin/SeekableBodyPlugin.php
310+
311+
-
312+
message: '#^Trait Http\\Client\\Common\\Plugin\\VersionBridgePlugin is used zero times and is not analysed\.$#'
313+
identifier: trait.unused
314+
count: 1
315+
path: src/Plugin/VersionBridgePlugin.php
316+
317+
-
318+
message: '#^Method Http\\Client\\Common\\PluginChain\:\:__invoke\(\) should return Http\\Promise\\Promise but returns mixed\.$#'
319+
identifier: return.type
320+
count: 1
321+
path: src/PluginChain.php
322+
323+
-
324+
message: '#^Parameter \#1 \$response of class Http\\Client\\Promise\\HttpFulfilledPromise constructor expects Psr\\Http\\Message\\ResponseInterface, mixed given\.$#'
325+
identifier: argument.type
326+
count: 1
80327
path: src/PluginClient.php
328+
329+
-
330+
message: '#^Parameter \#3 \$options of class Http\\Client\\Common\\PluginChain constructor expects array\{max_restarts\?\: int\}, array given\.$#'
331+
identifier: argument.type
332+
count: 1
333+
path: src/PluginClient.php
334+
335+
-
336+
message: '#^Parameter \#3 \$options of class Http\\Client\\Common\\PluginClient constructor expects array\{max_restarts\?\: int\}, array given\.$#'
337+
identifier: argument.type
338+
count: 1
339+
path: src/PluginClientBuilder.php
340+
341+
-
342+
message: '#^Trait Http\\Client\\Common\\VersionBridgeClient is used zero times and is not analysed\.$#'
343+
identifier: trait.unused
344+
count: 1
345+
path: src/VersionBridgeClient.php

spec/BatchClientSpec.php

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

0 commit comments

Comments
 (0)