2828use Symfony \Component \DependencyInjection \Reference ;
2929use Symfony \Component \ExpressionLanguage \ExpressionLanguage ;
3030use Symfony \Component \HttpKernel \Controller \ControllerResolverInterface ;
31+ use Symfony \Component \Routing \Generator \UrlGeneratorInterface ;
3132use Symfony \Component \Routing \Router ;
3233
3334class FOSHttpCacheExtensionTest extends TestCase
@@ -53,6 +54,38 @@ public function testConfigLoadVarnish(): void
5354 $ this ->assertTrue ($ container ->hasDefinition ('fos_http_cache.event_listener.tag ' ));
5455 }
5556
57+ public function testVarnishWithBaseUrlAutoResolvesAbsolutePath (): void
58+ {
59+ $ container = $ this ->createContainer ();
60+ $ this ->extension ->load ([$ this ->getBaseConfig ()], $ container );
61+
62+ $ this ->assertSame (
63+ UrlGeneratorInterface::ABSOLUTE_PATH ,
64+ $ container ->getParameter ('fos_http_cache.cache_manager.generate_url_type ' ),
65+ 'Varnish with base_url must auto-resolve to ABSOLUTE_PATH so the Host header uses base_url, not the CMS request hostname. '
66+ );
67+ }
68+
69+ public function testVarnishWithoutBaseUrlAutoResolvesAbsoluteUrl (): void
70+ {
71+ $ container = $ this ->createContainer ();
72+ $ config = [
73+ 'proxy_client ' => [
74+ 'varnish ' => [
75+ 'http ' => [
76+ 'servers ' => ['127.0.0.1 ' ],
77+ ],
78+ ],
79+ ],
80+ ];
81+ $ this ->extension ->load ([$ config ], $ container );
82+
83+ $ this ->assertSame (
84+ UrlGeneratorInterface::ABSOLUTE_URL ,
85+ $ container ->getParameter ('fos_http_cache.cache_manager.generate_url_type ' )
86+ );
87+ }
88+
5689 public function testConfigLoadVarnishCustomClient (): void
5790 {
5891 $ container = $ this ->createContainer ();
0 commit comments