1414
1515use chillerlan \HTTP \{CurlMultiClient , HTTPOptions , MultiResponseHandlerInterface };
1616use chillerlan \HTTP \Utils \QueryUtil ;
17+ use chillerlan \PHPUnitHttp \HttpFactoryTrait ;
1718use PHPUnit \Framework \Attributes \Group ;
1819use PHPUnit \Framework \TestCase ;
1920use Psr \Http \Client \ClientExceptionInterface ;
2526 *
2627 */
2728#[Group('slow ' )]
28- class CurlMultiClientTest extends TestCase{
29- use FactoryTrait ;
29+ final class CurlMultiClientTest extends TestCase{
30+ use HttpFactoryTrait ;
3031
31- protected CurlMultiClient $ http ;
32- protected MultiResponseHandlerInterface $ multiResponseHandler ;
32+ private CurlMultiClient $ http ;
33+ private MultiResponseHandlerInterface $ multiResponseHandler ;
3334
3435 protected function setUp ():void {
3536 $ this ->initFactories ();
@@ -45,32 +46,11 @@ protected function setUp():void{
4546 $ this ->http = new CurlMultiClient ($ this ->multiResponseHandler , $ this ->responseFactory , $ options );
4647 }
4748
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 {
7050
7151 return new class () implements MultiResponseHandlerInterface{
7252
73- protected array $ responses = [];
53+ private array $ responses = [];
7454
7555 public function handleResponse (
7656 ResponseInterface $ response ,
@@ -100,9 +80,27 @@ public function getResponses():array{
10080
10181 }
10282
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+
106104 public function testMultiRequest ():void {
107105 $ requests = $ this ->getRequests ();
108106
0 commit comments