File tree Expand file tree Collapse file tree 3 files changed +40
-0
lines changed
Expand file tree Collapse file tree 3 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1414use FOS \HttpCache \Exception \InvalidArgumentException ;
1515use FOS \HttpCache \ProxyClient \Invalidation \BanCapable ;
1616use FOS \HttpCache \ProxyClient \Invalidation \ClearCapable ;
17+ use FOS \HttpCache \ProxyClient \Invalidation \PrefixCapable ;
1718use FOS \HttpCache \ProxyClient \Invalidation \PurgeCapable ;
1819use FOS \HttpCache \ProxyClient \Invalidation \RefreshCapable ;
1920use FOS \HttpCache \ProxyClient \Invalidation \TagCapable ;
@@ -103,6 +104,21 @@ public function testInvalidateTags(): void
103104 $ this ->assertSame ($ multiplexer , $ multiplexer ->invalidateTags ($ tags ));
104105 }
105106
107+ public function testInvalidatePrefixes (): void
108+ {
109+ $ prefixes = ['example.com/one/ ' , 'example.com/two/ ' ];
110+
111+ $ mockClient = \Mockery::mock (PrefixCapable::class)
112+ ->shouldReceive ('invalidatePrefixes ' )
113+ ->once ()
114+ ->with ($ prefixes )
115+ ->getMock ();
116+
117+ $ multiplexer = new MultiplexerClient ([$ mockClient ]);
118+
119+ $ this ->assertSame ($ multiplexer , $ multiplexer ->invalidatePrefixes ($ prefixes ));
120+ }
121+
106122 public function testRefresh (): void
107123 {
108124 $ url = 'example.com ' ;
Original file line number Diff line number Diff line change @@ -33,6 +33,11 @@ public function testInvalidateTags(): void
3333 $ this ->assertSame ($ this ->noop , $ this ->noop ->invalidateTags (['tag123 ' ]));
3434 }
3535
36+ public function testInvalidatePrefixes (): void
37+ {
38+ $ this ->assertSame ($ this ->noop , $ this ->noop ->invalidatePrefixes (['example.com/one/ ' ]));
39+ }
40+
3641 public function testBanPath (): void
3742 {
3843 $ this ->assertSame ($ this ->noop , $ this ->noop ->banPath ('/123 ' ));
Original file line number Diff line number Diff line change @@ -236,4 +236,23 @@ function (RequestInterface $request) {
236236
237237 $ varnish ->refresh ('/fresh ' );
238238 }
239+
240+ public function testInvalidatePrefixes (): void
241+ {
242+ $ varnish = new Varnish ($ this ->httpDispatcher );
243+ $ this ->httpDispatcher ->shouldReceive ('invalidate ' )->once ()->with (
244+ \Mockery::on (
245+ function (RequestInterface $ request ) {
246+ $ this ->assertEquals ('BAN ' , $ request ->getMethod ());
247+ $ this ->assertEquals ('example.org ' , $ request ->getHeaderLine ('X-Host ' ));
248+ $ this ->assertEquals ('/one/ ' , $ request ->getHeaderLine ('X-Url ' ));
249+ $ this ->assertEquals ('text/html ' , $ request ->getHeaderLine ('X-Content-Type ' ));
250+
251+ return true ;
252+ }
253+ ),
254+ false
255+ );
256+ $ varnish ->invalidatePrefixes (['example.org/one/ ' ]);
257+ }
239258}
You can’t perform that action at this time.
0 commit comments