55namespace Http \HttplugBundle \Tests \Unit \DependencyInjection ;
66
77use Http \Adapter \Guzzle7 \Client ;
8+ use Http \Client \Common \Plugin \ThrottlePlugin ;
89use Http \Client \HttpClient ;
910use Http \Client \Plugin \Vcr \Recorder \InMemoryRecorder ;
1011use Http \HttplugBundle \Collector \PluginClientFactoryListener ;
@@ -79,7 +80,7 @@ public function testConfigLoadService(): void
7980
8081 public function testClientPlugins (): void
8182 {
82- $ this -> load ( [
83+ $ config = [
8384 'clients ' => [
8485 'acme ' => [
8586 'factory ' => 'httplug.factory.curl ' ,
@@ -130,6 +131,11 @@ public function testClientPlugins(): void
130131 'headers ' => ['X-FOO ' ],
131132 ],
132133 ],
134+ [
135+ 'query_defaults ' => [
136+ 'parameters ' => ['locale ' => 'en ' ],
137+ ],
138+ ],
133139 [
134140 'request_seekable_body ' => [
135141 'use_file_buffer ' => true ,
@@ -138,11 +144,6 @@ public function testClientPlugins(): void
138144 [
139145 'response_seekable_body ' => true ,
140146 ],
141- [
142- 'query_defaults ' => [
143- 'parameters ' => ['locale ' => 'en ' ],
144- ],
145- ],
146147 [
147148 'authentication ' => [
148149 'my_basic ' => [
@@ -165,7 +166,16 @@ public function testClientPlugins(): void
165166 ],
166167 ],
167168 ],
168- ]);
169+ ];
170+ if (class_exists (ThrottlePlugin::class)) {
171+ $ config ['clients ' ]['acme ' ]['plugins ' ][] = [
172+ 'throttle ' => [
173+ 'name ' => 'limiter.test ' ,
174+ ],
175+ ];
176+ }
177+
178+ $ this ->load ($ config );
169179
170180 $ plugins = [
171181 'httplug.client.acme.plugin.decoder ' ,
@@ -178,13 +188,16 @@ public function testClientPlugins(): void
178188 'httplug.client.acme.plugin.header_defaults ' ,
179189 'httplug.client.acme.plugin.header_set ' ,
180190 'httplug.client.acme.plugin.header_remove ' ,
191+ 'httplug.client.acme.plugin.query_defaults ' ,
181192 'httplug.client.acme.plugin.request_seekable_body ' ,
182193 'httplug.client.acme.plugin.response_seekable_body ' ,
183- 'httplug.client.acme.plugin.query_defaults ' ,
184194 'httplug.client.acme.authentication.my_basic ' ,
185195 'httplug.client.acme.plugin.cache ' ,
186196 'httplug.client.acme.plugin.error ' ,
187197 ];
198+ if (\class_exists (ThrottlePlugin::class)) {
199+ $ plugins [] = 'httplug.client.acme.plugin.throttle ' ;
200+ }
188201 $ pluginReferences = array_map (function ($ id ) {
189202 return new Reference ($ id );
190203 }, $ plugins );
0 commit comments