@@ -84,7 +84,24 @@ public function testNoCustomTtl(): void
8484 $ this ->assertFalse ($ response ->headers ->has (CustomTtlListener::SMAXAGE_BACKUP ));
8585 }
8686
87- public function testCleanup (): void
87+ public function testNoCustomTtlNoFallback ()
88+ {
89+ $ ttlListener = new CustomTtlListener ('X-Reverse-Proxy-TTL ' , false , false );
90+ $ request = Request::create ('http://example.com/foo ' , 'GET ' );
91+ $ response = new Response ('' , 200 , [
92+ 'Cache-Control ' => 'max-age=30, s-maxage=33 ' ,
93+ ]);
94+ $ event = new CacheEvent ($ this ->kernel , $ request , $ response );
95+
96+ $ ttlListener ->useCustomTtl ($ event );
97+ $ response = $ event ->getResponse ();
98+
99+ $ this ->assertInstanceOf (Response::class, $ response );
100+ $ this ->assertSame ('0 ' , $ response ->headers ->getCacheControlDirective ('s-maxage ' ));
101+ $ this ->assertTrue ($ response ->headers ->has (CustomTtlListener::SMAXAGE_BACKUP ));
102+ }
103+
104+ public function testCleanup ()
88105 {
89106 $ ttlListener = new CustomTtlListener ();
90107 $ request = Request::create ('http://example.com/foo ' , 'GET ' );
@@ -105,7 +122,27 @@ public function testCleanup(): void
105122 $ this ->assertFalse ($ response ->headers ->has (CustomTtlListener::SMAXAGE_BACKUP ));
106123 }
107124
108- public function testCleanupNoSmaxage (): void
125+ public function testCleanupNoReverseProxyTtl ()
126+ {
127+ $ ttlListener = new CustomTtlListener ();
128+ $ request = Request::create ('http://example.com/foo ' , 'GET ' );
129+ $ response = new Response ('' , 200 , [
130+ 'Cache-Control ' => 's-maxage=0, max-age=30 ' ,
131+ CustomTtlListener::SMAXAGE_BACKUP => '60 ' ,
132+ ]);
133+ $ event = new CacheEvent ($ this ->kernel , $ request , $ response );
134+
135+ $ ttlListener ->cleanResponse ($ event );
136+ $ response = $ event ->getResponse ();
137+
138+ $ this ->assertInstanceOf (Response::class, $ response );
139+ $ this ->assertTrue ($ response ->headers ->hasCacheControlDirective ('s-maxage ' ));
140+ $ this ->assertSame ('60 ' , $ response ->headers ->getCacheControlDirective ('s-maxage ' ));
141+ $ this ->assertFalse ($ response ->headers ->has ('X-Reverse-Proxy-TTL ' ));
142+ $ this ->assertFalse ($ response ->headers ->has (CustomTtlListener::SMAXAGE_BACKUP ));
143+ }
144+
145+ public function testCleanupNoSmaxage ()
109146 {
110147 $ ttlListener = new CustomTtlListener ();
111148 $ request = Request::create ('http://example.com/foo ' , 'GET ' );
0 commit comments