mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 15:13:59 -06:00
Deleted specific factory by replacing it by ConfigAbstractFactory
This commit is contained in:
parent
a7d308c585
commit
84c4631124
@ -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',
|
||||
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shlinkio\Shlink\Rest\Action;
|
||||
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||
|
||||
class HealthActionFactory
|
||||
{
|
||||
public function __invoke(ContainerInterface $container)
|
||||
{
|
||||
$em = $container->get(EntityManager::class);
|
||||
$options = $container->get(AppOptions::class);
|
||||
$logger = $container->get('Logger_Shlink');
|
||||
return new HealthAction($em->getConnection(), $options, $logger);
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ use UnexpectedValueException;
|
||||
|
||||
use function time;
|
||||
|
||||
/** @deprecated */
|
||||
class JWTService implements JWTServiceInterface
|
||||
{
|
||||
/** @var AppOptions */
|
||||
|
@ -1,44 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace ShlinkioTest\Shlink\Rest\Action;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Shlinkio\Shlink\Core\Options\AppOptions;
|
||||
use Shlinkio\Shlink\Rest\Action;
|
||||
use Zend\ServiceManager\ServiceManager;
|
||||
|
||||
class HealthActionFactoryTest extends TestCase
|
||||
{
|
||||
/** @var Action\HealthActionFactory */
|
||||
private $factory;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user