|
7 | 7 | use Http\HttplugBundle\Collector\PluginClientFactoryListener; |
8 | 8 | use Http\HttplugBundle\DependencyInjection\HttplugExtension; |
9 | 9 | use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase; |
| 10 | +use Symfony\Component\DependencyInjection\Definition; |
10 | 11 | use Symfony\Component\DependencyInjection\Reference; |
11 | 12 | use Symfony\Component\HttpKernel\Kernel; |
12 | 13 | use Http\Adapter\Guzzle6\Client; |
@@ -261,6 +262,47 @@ public function testCachePluginConfigCacheKeyGeneratorReference(): void |
261 | 262 | $this->assertSame('header_cache_key_generator', (string) $config['cache_key_generator']); |
262 | 263 | } |
263 | 264 |
|
| 265 | + public function testCachePluginConfigCacheListenersDefinition(): void |
| 266 | + { |
| 267 | + $this->load([ |
| 268 | + 'plugins' => [ |
| 269 | + 'cache' => [ |
| 270 | + 'cache_pool' => 'my_cache_pool', |
| 271 | + 'config' => [ |
| 272 | + 'cache_listeners' => [ |
| 273 | + '\Http\Client\Common\Plugin\Cache\Listener\AddHeaderCacheListener' |
| 274 | + ], |
| 275 | + ], |
| 276 | + ], |
| 277 | + ], |
| 278 | + ]); |
| 279 | + |
| 280 | + $cachePlugin = $this->container->findDefinition('httplug.plugin.cache'); |
| 281 | + |
| 282 | + $config = $cachePlugin->getArgument(2); |
| 283 | + $this->assertArrayHasKey('cache_listeners', $config); |
| 284 | + $this->assertContainsOnlyInstancesOf(Definition::class, $config['cache_listeners']); |
| 285 | + } |
| 286 | + |
| 287 | + public function testCachePluginInvalidConfigCacheListenersDefinition(): void |
| 288 | + { |
| 289 | + $this->load([ |
| 290 | + 'plugins' => [ |
| 291 | + 'cache' => [ |
| 292 | + 'cache_pool' => 'my_cache_pool', |
| 293 | + 'config' => [ |
| 294 | + 'cache_listeners' => [], |
| 295 | + ], |
| 296 | + ], |
| 297 | + ], |
| 298 | + ]); |
| 299 | + |
| 300 | + $cachePlugin = $this->container->findDefinition('httplug.plugin.cache'); |
| 301 | + |
| 302 | + $config = $cachePlugin->getArgument(2); |
| 303 | + $this->assertArrayNotHasKey('cache_listeners', $config); |
| 304 | + } |
| 305 | + |
264 | 306 | public function testContentTypePluginAllowedOptions(): void |
265 | 307 | { |
266 | 308 | $this->load([ |
|
0 commit comments