Skip to content

Commit

Permalink
Remove the Guzzle client exception
Browse files Browse the repository at this point in the history
  • Loading branch information
darkweak committed Dec 15, 2021
1 parent c2d7378 commit 43ec5a2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 47 deletions.
3 changes: 1 addition & 2 deletions src/HttpCache/SouinPurger.php
Expand Up @@ -14,7 +14,6 @@
namespace ApiPlatform\HttpCache;

use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\GuzzleException;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;

Expand Down Expand Up @@ -105,7 +104,7 @@ private function banRegex(string $regex): void
[]
)]
);
} catch (GuzzleException $e) {
} catch (\Exception $e) {
$this->logger->warning($e->getMessage());
}
}
Expand Down
45 changes: 0 additions & 45 deletions tests/HttpCache/SouinPurgerTest.php
Expand Up @@ -16,7 +16,6 @@
use ApiPlatform\Core\Tests\ProphecyTrait;
use ApiPlatform\HttpCache\SouinPurger;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Promise\PromiseInterface;
use GuzzleHttp\Psr7\Response;
use LogicException;
Expand Down Expand Up @@ -246,48 +245,4 @@ public function getConfig($option = null)
],
], $client2->requests[0]);
}

public function testPurgeWithErrorOnClient()
{
$guzzleExceptionProphecy = $this->prophesize(ClientException::class);
$client = new class($guzzleExceptionProphecy->reveal()) implements ClientInterface {
public $request = [];
private $guzzleExceptionProphecy;

public function __construct($guzzleExceptionProphecy)
{
$this->guzzleExceptionProphecy = $guzzleExceptionProphecy;
}

public function send(RequestInterface $request, array $options = []): ResponseInterface
{
throw new LogicException('Not implemented');
}

public function sendAsync(RequestInterface $request, array $options = []): PromiseInterface
{
throw new LogicException('Not implemented');
}

public function request($method, $uri, array $options = []): ResponseInterface
{
throw $this->guzzleExceptionProphecy;
}

public function requestAsync($method, $uri, array $options = []): PromiseInterface
{
throw new LogicException('Not implemented');
}

public function getConfig($option = null)
{
throw new LogicException('Not implemented');
}
};
$loggerProphecy = $this->prophesize(LoggerInterface::class);
$loggerProphecy->warning('')->shouldBeCalled();

$purger = new SouinPurger([$client], $loggerProphecy->reveal(), 'http://dummy_host', '/dummy_api_path', 'souin_auth_cookie');
$purger->purge(['/foo']);
}
}

0 comments on commit 43ec5a2

Please sign in to comment.