-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update deps and fix deprecation from AMQP lib
- Loading branch information
Showing
11 changed files
with
143 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
version: '3' | ||
|
||
services: | ||
shlink_common_php: | ||
user: 1000:1000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
version: '3' | ||
|
||
services: | ||
shlink_common_php: | ||
container_name: shlink_common_php | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shlinkio\Shlink\Common\RabbitMq; | ||
|
||
use PhpAmqpLib\Connection\AMQPConnectionConfig; | ||
use Psr\Container\ContainerInterface; | ||
|
||
class AMQPConfigFactory | ||
{ | ||
public function __invoke(ContainerInterface $container): AMQPConnectionConfig | ||
{ | ||
$rabbitMqConfig = $container->get('config')['rabbitmq'] ?? []; | ||
|
||
$config = new AMQPConnectionConfig(); | ||
$config->setHost($rabbitMqConfig['host']); | ||
$config->setPort($rabbitMqConfig['port']); | ||
$config->setUser($rabbitMqConfig['user']); | ||
$config->setPassword($rabbitMqConfig['password']); | ||
$config->setVhost($rabbitMqConfig['vhost']); | ||
$config->setIsSecure($rabbitMqConfig['use_ssl'] ?? false); | ||
|
||
// Make sure we do not try to connect until the first time we need to access the server | ||
$config->setIsLazy(true); | ||
|
||
return $config; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ShlinkioTest\Shlink\Common\RabbitMq; | ||
|
||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\Attributes\Test; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Psr\Container\ContainerInterface; | ||
use Shlinkio\Shlink\Common\RabbitMq\AMQPConfigFactory; | ||
|
||
class AMQPConfigFactoryTest extends TestCase | ||
{ | ||
private AMQPConfigFactory $factory; | ||
private MockObject & ContainerInterface $container; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->factory = new AMQPConfigFactory(); | ||
$this->container = $this->createMock(ContainerInterface::class); | ||
} | ||
|
||
#[Test, DataProvider('provideSsl')] | ||
public function properConnectionObjectIsCreated(array $useSsl): void | ||
{ | ||
$this->container->expects($this->once())->method('get')->with('config')->willReturn([ | ||
'rabbitmq' => [ | ||
...$useSsl, | ||
'host' => 'host', | ||
'port' => 1111, | ||
'user' => 'user', | ||
'password' => 'password', | ||
'vhost' => 'vhost', | ||
], | ||
]); | ||
|
||
$config = ($this->factory)($this->container); | ||
|
||
self::assertEquals($useSsl['use_ssl'] ?? false, $config->isSecure()); | ||
self::assertEquals('host', $config->getHost()); | ||
self::assertEquals(1111, $config->getPort()); | ||
self::assertEquals('user', $config->getUser()); | ||
self::assertEquals('password', $config->getPassword()); | ||
self::assertEquals('vhost', $config->getVhost()); | ||
} | ||
|
||
public static function provideSsl(): iterable | ||
{ | ||
yield 'no ssl set' => [[]]; | ||
yield 'no ssl' => [['use_ssl' => false]]; | ||
yield 'ssl' => [['use_ssl' => true]]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters