Skip to content

Commit

Permalink
Merge pull request #1 from JivoSite/symfony5
Browse files Browse the repository at this point in the history
Prepare bundle for Symfony 5
  • Loading branch information
EugenGanshorn authored Apr 8, 2020
2 parents 390c69f + d60c917 commit f155806
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
"require": {
"php": "^7.3",
"guzzlehttp/guzzle": "^6.3",
"eightpoints/guzzle-bundle": "^7.5",
"eightpoints/guzzle-bundle": "^8.0",
"caseyamcl/guzzle_retry_middleware": "^2.2",
"symfony/dependency-injection": "~2.7|~3.0|~4.0"
"symfony/dependency-injection": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^8.1",
Expand Down
10 changes: 5 additions & 5 deletions src/GuzzleBundleRetryPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace EugenGanshorn\Bundle\GuzzleBundleRetryPlugin;

use EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin;
use EightPoints\Bundle\GuzzleBundle\PluginInterface;
use GuzzleRetry\GuzzleRetryMiddleware;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand All @@ -11,7 +11,7 @@
use Symfony\Component\ExpressionLanguage\Expression;
use Symfony\Component\HttpKernel\Bundle\Bundle;

class GuzzleBundleRetryPlugin extends Bundle implements EightPointsGuzzleBundlePlugin
class GuzzleBundleRetryPlugin extends Bundle implements PluginInterface
{
/**
* The name of this plugin. It will be used as the configuration key.
Expand All @@ -28,7 +28,7 @@ public function getPluginName(): string
*
* @return void
*/
public function addConfiguration(ArrayNodeDefinition $pluginNode)
public function addConfiguration(ArrayNodeDefinition $pluginNode): void
{
$pluginNode
->canBeEnabled()
Expand Down Expand Up @@ -70,7 +70,7 @@ public function addConfiguration(ArrayNodeDefinition $pluginNode)
*
* @return void
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
}

Expand All @@ -84,7 +84,7 @@ public function load(array $configs, ContainerBuilder $container)
*
* @return void
*/
public function loadForClient(array $config, ContainerBuilder $container, string $clientName, Definition $handler)
public function loadForClient(array $config, ContainerBuilder $container, string $clientName, Definition $handler): void
{
if ($config['retry_enabled']) {
$logger = new Definition(Logger::class);
Expand Down
2 changes: 1 addition & 1 deletion src/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function callback(
$delay,
Request $request,
$options,
Response $response
?Response $response = null
) {
$this->logger->info(
sprintf(
Expand Down
4 changes: 2 additions & 2 deletions tests/GuzzleBundleRetryPluginTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundlePlugin;
use EightPoints\Bundle\GuzzleBundle\PluginInterface;
use EugenGanshorn\Bundle\GuzzleBundleRetryPlugin\GuzzleBundleRetryPlugin;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpKernel\Bundle\Bundle;
Expand All @@ -18,7 +18,7 @@ public function setUp(): void

public function testSubClassesOfPlugin()
{
$this->assertInstanceOf(EightPointsGuzzleBundlePlugin::class, $this->plugin);
$this->assertInstanceOf(PluginInterface::class, $this->plugin);
$this->assertInstanceOf(Bundle::class, $this->plugin);
}

Expand Down
15 changes: 15 additions & 0 deletions tests/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Psr\Log\Test\TestLogger;

class LoggerTest extends TestCase
{
Expand Down Expand Up @@ -42,4 +43,18 @@ public function testCallback()
$sut->setFormatter($formatter);
$sut->callback(7, 42.7, $request, [], $response);
}

public function testCallbackWithoutResponse(): void
{
$request = new Request('POST', '/test');
$logger = new TestLogger();
$formatter = new MessageFormatter();

$sut = new Logger();
$sut->setLogger($logger);
$sut->setFormatter($formatter);
$sut->callback(7, 42.7, $request, []);

$this->assertTrue($logger->hasInfoThatContains('will wait 42.70 seconds and try it again, this is attempt #7'));
}
}

0 comments on commit f155806

Please sign in to comment.