From 84c4631124d9cb542c502a42315fc88af6a81f01 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 20 Nov 2019 20:18:21 +0100 Subject: [PATCH] Deleted specific factory by replacing it by ConfigAbstractFactory --- module/Rest/config/dependencies.config.php | 4 +- .../Rest/src/Action/HealthActionFactory.php | 20 --------- module/Rest/src/Authentication/JWTService.php | 1 + .../test/Action/HealthActionFactoryTest.php | 44 ------------------- 4 files changed, 4 insertions(+), 65 deletions(-) delete mode 100644 module/Rest/src/Action/HealthActionFactory.php delete mode 100644 module/Rest/test/Action/HealthActionFactoryTest.php diff --git a/module/Rest/config/dependencies.config.php b/module/Rest/config/dependencies.config.php index 54f380b3..5ef1ecba 100644 --- a/module/Rest/config/dependencies.config.php +++ b/module/Rest/config/dependencies.config.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Shlinkio\Shlink\Rest; +use Doctrine\DBAL\Connection; use Psr\Log\LoggerInterface; use Shlinkio\Shlink\Core\Options\AppOptions; use Shlinkio\Shlink\Core\Service; @@ -20,7 +21,7 @@ return [ ApiKeyService::class => ConfigAbstractFactory::class, Action\AuthenticateAction::class => ConfigAbstractFactory::class, - Action\HealthAction::class => Action\HealthActionFactory::class, + Action\HealthAction::class => ConfigAbstractFactory::class, Action\ShortUrl\CreateShortUrlAction::class => ConfigAbstractFactory::class, Action\ShortUrl\SingleStepCreateShortUrlAction::class => ConfigAbstractFactory::class, Action\ShortUrl\EditShortUrlAction::class => ConfigAbstractFactory::class, @@ -48,6 +49,7 @@ return [ ApiKeyService::class => ['em'], Action\AuthenticateAction::class => [ApiKeyService::class, Authentication\JWTService::class, 'Logger_Shlink'], + Action\HealthAction::class => [Connection::class, AppOptions::class, 'Logger_Shlink'], Action\ShortUrl\CreateShortUrlAction::class => [ Service\UrlShortener::class, 'config.url_shortener.domain', diff --git a/module/Rest/src/Action/HealthActionFactory.php b/module/Rest/src/Action/HealthActionFactory.php deleted file mode 100644 index 269a8f4d..00000000 --- a/module/Rest/src/Action/HealthActionFactory.php +++ /dev/null @@ -1,20 +0,0 @@ -get(EntityManager::class); - $options = $container->get(AppOptions::class); - $logger = $container->get('Logger_Shlink'); - return new HealthAction($em->getConnection(), $options, $logger); - } -} diff --git a/module/Rest/src/Authentication/JWTService.php b/module/Rest/src/Authentication/JWTService.php index 841527e4..77ec6728 100644 --- a/module/Rest/src/Authentication/JWTService.php +++ b/module/Rest/src/Authentication/JWTService.php @@ -12,6 +12,7 @@ use UnexpectedValueException; use function time; +/** @deprecated */ class JWTService implements JWTServiceInterface { /** @var AppOptions */ diff --git a/module/Rest/test/Action/HealthActionFactoryTest.php b/module/Rest/test/Action/HealthActionFactoryTest.php deleted file mode 100644 index 3ecb15c1..00000000 --- a/module/Rest/test/Action/HealthActionFactoryTest.php +++ /dev/null @@ -1,44 +0,0 @@ -factory = new Action\HealthActionFactory(); - } - - /** @test */ - public function serviceIsCreatedExtractingConnectionFromEntityManager() - { - $em = $this->prophesize(EntityManager::class); - $conn = $this->prophesize(Connection::class); - - $getConnection = $em->getConnection()->willReturn($conn->reveal()); - - $sm = new ServiceManager(['services' => [ - 'Logger_Shlink' => $this->prophesize(LoggerInterface::class)->reveal(), - AppOptions::class => $this->prophesize(AppOptions::class)->reveal(), - EntityManager::class => $em->reveal(), - ]]); - - $instance = ($this->factory)($sm, ''); - - $this->assertInstanceOf(Action\HealthAction::class, $instance); - $getConnection->shouldHaveBeenCalledOnce(); - } -}