Skip to content

Commit

Permalink
Fix EZP-23690: HttpCache: LocalPurgeClient uses deprecated X-Group-Lo…
Browse files Browse the repository at this point in the history
…cation-Id

> https://jira.ez.no/browse/EZP-23690

`LocalPurgeClient` was forgotten in refactoring.
We shouldn't use `PURGE` method and `X-Group-Location-Id`.
  • Loading branch information
Jérôme Vieilledent committed Nov 26, 2014
1 parent bdb511a commit ea728cd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions eZ/Publish/Core/MVC/Symfony/Cache/Http/LocalPurgeClient.php
Expand Up @@ -43,8 +43,8 @@ public function purge( $locationIds )
if ( !is_array( $locationIds ) )
$locationIds = array( $locationIds );

$purgeRequest = Request::create( 'http://localhost/', 'PURGE' );
$purgeRequest->headers->set( 'X-Group-Location-Id', implode( '; ', $locationIds ) );
$purgeRequest = Request::create( 'http://localhost/', 'BAN' );
$purgeRequest->headers->set( 'X-Location-Id', '(' . implode( '|', $locationIds ) . ')' );
$this->cacheStore->purgeByRequest( $purgeRequest );
}

Expand Down
Expand Up @@ -11,29 +11,26 @@

use eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient;
use PHPUnit_Framework_TestCase;
use Symfony\Component\HttpFoundation\Request;

class LocalPurgeClientTest extends PHPUnit_Framework_TestCase
{
/**
* @covers eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient::__construct
* @covers eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient::purge
*/
public function testPurge()
{
$locationIds = array( 123, 456, 789 );
$expectedBanRequest = Request::create( 'http://localhost', 'BAN' );
$expectedBanRequest->headers->set( 'X-Location-Id', '(' . implode( '|', $locationIds ) . ')' );

$cacheStore = $this->getMock( 'eZ\\Publish\\Core\\MVC\\Symfony\\Cache\\Http\\ContentPurger' );
$cacheStore
->expects( $this->once() )
->method( 'purgeByRequest' )
->with( $this->isInstanceOf( 'Symfony\\Component\\HttpFoundation\\Request' ) );
->with( $this->equalTo( $expectedBanRequest ) );

$purgeClient = new LocalPurgeClient( $cacheStore );
$purgeClient->purge( array( 123, 456, 789 ) );
$purgeClient->purge( $locationIds );
}

/**
* @covers eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient::__construct
* @covers eZ\Publish\Core\MVC\Symfony\Cache\Http\LocalPurgeClient::purgeAll
*/
public function testPurgeAll()
{
$cacheStore = $this->getMock( 'eZ\\Publish\\Core\\MVC\\Symfony\\Cache\\Http\\ContentPurger' );
Expand Down

0 comments on commit ea728cd

Please sign in to comment.