Skip to content

Commit

Permalink
minor #32354 [Messenger] Use ConnectionRegistry instead of RegistryIn…
Browse files Browse the repository at this point in the history
…terface (derrabus)

This PR was merged into the 4.4 branch.

Discussion
----------

[Messenger] Use ConnectionRegistry instead of RegistryInterface

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | N/A
| License       | MIT
| Doc PR        | N/A

This PR changes the constructor type-hint on `DoctrineTransportFactory` from `Symfony\Bridge\Doctrine\RegistryInterface` to the smaller `Doctrine\Common\Persistence\ConnectionRegistry`. Since we only call the `getConnection()` method, this interface is sufficient.

This change allows to use the factory without the Doctrine bridge and makes it easier to use it stand-alone.

Commits
-------

ce6a5ad Use ConnectionRegistry instead of RegistryInterface.
  • Loading branch information
fabpot committed Jul 4, 2019
2 parents b7c9fcf + ce6a5ad commit e3927b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
Expand Up @@ -11,8 +11,8 @@

namespace Symfony\Component\Messenger\Tests\Transport\Doctrine;

use Doctrine\Common\Persistence\ConnectionRegistry;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Component\Messenger\Transport\Doctrine\Connection;
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransport;
use Symfony\Component\Messenger\Transport\Doctrine\DoctrineTransportFactory;
Expand All @@ -23,7 +23,7 @@ class DoctrineTransportFactoryTest extends TestCase
public function testSupports()
{
$factory = new DoctrineTransportFactory(
$this->getMockBuilder(RegistryInterface::class)->getMock()
$this->getMockBuilder(ConnectionRegistry::class)->getMock()
);

$this->assertTrue($factory->supports('doctrine://default', []));
Expand All @@ -35,7 +35,7 @@ public function testCreateTransport()
$connection = $this->getMockBuilder(\Doctrine\DBAL\Connection::class)
->disableOriginalConstructor()
->getMock();
$registry = $this->getMockBuilder(RegistryInterface::class)->getMock();
$registry = $this->getMockBuilder(ConnectionRegistry::class)->getMock();
$registry->expects($this->once())
->method('getConnection')
->willReturn($connection);
Expand All @@ -55,7 +55,7 @@ public function testCreateTransport()
*/
public function testCreateTransportMustThrowAnExceptionIfManagerIsNotFound()
{
$registry = $this->getMockBuilder(RegistryInterface::class)->getMock();
$registry = $this->getMockBuilder(ConnectionRegistry::class)->getMock();
$registry->expects($this->once())
->method('getConnection')
->willReturnCallback(function () {
Expand Down
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\Messenger\Transport\Doctrine;

use Symfony\Bridge\Doctrine\RegistryInterface;
use Doctrine\Common\Persistence\ConnectionRegistry;
use Symfony\Component\Messenger\Exception\TransportException;
use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface;
use Symfony\Component\Messenger\Transport\TransportFactoryInterface;
Expand All @@ -24,7 +24,7 @@ class DoctrineTransportFactory implements TransportFactoryInterface
{
private $registry;

public function __construct(RegistryInterface $registry)
public function __construct(ConnectionRegistry $registry)
{
$this->registry = $registry;
}
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Messenger/composer.json
Expand Up @@ -25,7 +25,6 @@
"symfony/console": "^3.4|^4.0|^5.0",
"symfony/dependency-injection": "^3.4.19|^4.1.8|^5.0",
"symfony/error-catcher": "^4.4|^5.0",
"symfony/doctrine-bridge": "^3.4|^4.0|^5.0",
"symfony/event-dispatcher": "^4.3|^5.0",
"symfony/http-kernel": "^4.4|^5.0",
"symfony/process": "^3.4|^4.0|^5.0",
Expand Down

0 comments on commit e3927b6

Please sign in to comment.