Skip to content

Commit aa76ae2

Browse files
committed
Fix the Varnish purger
1 parent 0992790 commit aa76ae2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/HttpCache/VarnishPurger.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public function purge(array $iris)
4848
return sprintf('(^|\,)%s($|\,)', preg_quote($iri));
4949
}, $iris);
5050

51-
$regex = isset($parts[1]) ? sprintf('(%s)', implode(')|(', $parts)) : $parts[0];
51+
$regex = count($parts) > 1 ? sprintf('(%s)', implode(')|(', $parts)) : array_shift($parts);
5252

5353
foreach ($this->clients as $client) {
54-
$client->requestAsync('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => $regex]]);
54+
$client->request('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => $regex]]);
5555
}
5656
}
5757
}

tests/HttpCache/VarnishPurgerTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@ class VarnishPurgerTest extends \PHPUnit_Framework_TestCase
2525
public function testPurge()
2626
{
2727
$clientProphecy1 = $this->prophesize(ClientInterface::class);
28-
$clientProphecy1->requestAsync('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => '(^|\,)/foo($|\,)']])->willReturn(new Response())->shouldBeCalled();
29-
$clientProphecy1->requestAsync('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => '((^|\,)/foo($|\,))|((^|\,)/bar($|\,))']])->willReturn(new Response())->shouldBeCalled();
28+
$clientProphecy1->request('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => '(^|\,)/foo($|\,)']])->willReturn(new Response())->shouldBeCalled();
29+
$clientProphecy1->request('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => '((^|\,)/foo($|\,))|((^|\,)/bar($|\,))']])->willReturn(new Response())->shouldBeCalled();
3030

3131
$clientProphecy2 = $this->prophesize(ClientInterface::class);
32-
$clientProphecy2->requestAsync('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => '(^|\,)/foo($|\,)']])->willReturn(new Response())->shouldBeCalled();
33-
$clientProphecy2->requestAsync('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => '((^|\,)/foo($|\,))|((^|\,)/bar($|\,))']])->willReturn(new Response())->shouldBeCalled();
32+
$clientProphecy2->request('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => '(^|\,)/foo($|\,)']])->willReturn(new Response())->shouldBeCalled();
33+
$clientProphecy2->request('BAN', '', ['headers' => ['ApiPlatform-Ban-Regex' => '((^|\,)/foo($|\,))|((^|\,)/bar($|\,))']])->willReturn(new Response())->shouldBeCalled();
3434

3535
$purger = new VarnishPurger([$clientProphecy1->reveal(), $clientProphecy2->reveal()]);
3636
$purger->purge(['/foo']);
37-
$purger->purge(['/foo', '/bar']);
37+
$purger->purge(['/foo' => '/foo', '/bar' => '/bar']);
3838
}
3939

4040
public function testEmptyTags()
4141
{
4242
$clientProphecy1 = $this->prophesize(ClientInterface::class);
43-
$clientProphecy1->requestAsync()->shouldNotBeCalled();
43+
$clientProphecy1->request()->shouldNotBeCalled();
4444

4545
$purger = new VarnishPurger([$clientProphecy1->reveal()]);
4646
$purger->purge([]);

0 commit comments

Comments
 (0)