14
14
15
15
use chillerlan \HTTP \{CurlMultiClient , HTTPOptions , MultiResponseHandlerInterface };
16
16
use chillerlan \HTTP \Utils \QueryUtil ;
17
+ use chillerlan \PHPUnitHttp \HttpFactoryTrait ;
17
18
use PHPUnit \Framework \Attributes \Group ;
18
19
use PHPUnit \Framework \TestCase ;
19
20
use Psr \Http \Client \ClientExceptionInterface ;
25
26
*
26
27
*/
27
28
#[Group('slow ' )]
28
- class CurlMultiClientTest extends TestCase{
29
- use FactoryTrait ;
29
+ final class CurlMultiClientTest extends TestCase{
30
+ use HttpFactoryTrait ;
30
31
31
- protected CurlMultiClient $ http ;
32
- protected MultiResponseHandlerInterface $ multiResponseHandler ;
32
+ private CurlMultiClient $ http ;
33
+ private MultiResponseHandlerInterface $ multiResponseHandler ;
33
34
34
35
protected function setUp ():void {
35
36
$ this ->initFactories ();
@@ -45,32 +46,11 @@ protected function setUp():void{
45
46
$ this ->http = new CurlMultiClient ($ this ->multiResponseHandler , $ this ->responseFactory , $ options );
46
47
}
47
48
48
- protected function getRequests ():array {
49
-
50
- $ ids = [
51
- [1 , 2 , 6 , 11 , 15 , 23 , 24 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , 64 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 ],
52
- [77 , 78 , 79 , 80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 , 100 , 101 ],
53
- ];
54
-
55
- $ requests = [];
56
-
57
- foreach ($ ids as $ chunk ){
58
- foreach (['de ' , 'en ' , 'es ' , 'fr ' , 'zh ' ] as $ lang ){
59
- $ requests [] = $ this ->requestFactory ->createRequest (
60
- 'GET ' ,
61
- 'https://api.guildwars2.com/v2/items? ' .QueryUtil::build (['lang ' => $ lang , 'ids ' => implode (', ' , $ chunk )])
62
- );
63
- }
64
- }
65
-
66
- return $ requests ;
67
- }
68
-
69
- protected function getTestResponseHandler ():MultiResponseHandlerInterface {
49
+ private function getTestResponseHandler ():MultiResponseHandlerInterface {
70
50
71
51
return new class () implements MultiResponseHandlerInterface{
72
52
73
- protected array $ responses = [];
53
+ private array $ responses = [];
74
54
75
55
public function handleResponse (
76
56
ResponseInterface $ response ,
@@ -100,9 +80,27 @@ public function getResponses():array{
100
80
101
81
}
102
82
103
- /**
104
- * @todo
105
- */
83
+ private function getRequests ():array {
84
+
85
+ $ ids = [
86
+ [1 , 2 , 6 , 11 , 15 , 23 , 24 , 56 , 57 , 58 , 59 , 60 , 61 , 62 , 63 , 64 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 ],
87
+ [77 , 78 , 79 , 80 , 81 , 82 , 83 , 84 , 85 , 86 , 87 , 88 , 89 , 90 , 91 , 92 , 93 , 94 , 95 , 96 , 97 , 98 , 99 , 100 , 101 ],
88
+ ];
89
+
90
+ $ requests = [];
91
+
92
+ foreach ($ ids as $ chunk ){
93
+ foreach (['de ' , 'en ' , 'es ' , 'fr ' , 'zh ' ] as $ lang ){
94
+ $ requests [] = $ this ->requestFactory ->createRequest (
95
+ 'GET ' ,
96
+ 'https://api.guildwars2.com/v2/items? ' .QueryUtil::build (['lang ' => $ lang , 'ids ' => implode (', ' , $ chunk )])
97
+ );
98
+ }
99
+ }
100
+
101
+ return $ requests ;
102
+ }
103
+
106
104
public function testMultiRequest ():void {
107
105
$ requests = $ this ->getRequests ();
108
106
0 commit comments