Skip to content

Commit

Permalink
Merge branch '1.12.x' into 2.0.x
Browse files Browse the repository at this point in the history
* 1.12.x:
  Skip resetting managers when proxy-manager is not installed
  • Loading branch information
alcaeus committed Dec 18, 2019
2 parents fd15f18 + 5d477e6 commit 522c166
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 6 additions & 0 deletions Registry.php
Expand Up @@ -3,9 +3,11 @@
namespace Doctrine\Bundle\DoctrineBundle;

use Doctrine\ORM\ORMException;
use ProxyManager\Proxy\LazyLoadingInterface;
use Psr\Container\ContainerInterface;
use Symfony\Bridge\Doctrine\ManagerRegistry;
use Symfony\Contracts\Service\ResetInterface;
use function interface_exists;

/**
* References all Doctrine connections and entity managers in a given Container.
Expand Down Expand Up @@ -50,6 +52,10 @@ public function getAliasNamespace($alias)

public function reset() : void
{
if (! interface_exists(LazyLoadingInterface::class)) {
return;
}

foreach (array_keys($this->getManagerNames()) as $managerName) {
$this->resetManager($managerName);
}
Expand Down
8 changes: 2 additions & 6 deletions Tests/RegistryTest.php
Expand Up @@ -123,17 +123,13 @@ public function testResetUnknownEntityManager()
$registry->resetManager('default');
}

/**
* @group legacy
*/
public function testReset()
{
$em = new stdClass();
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
$container->expects($this->once())
->method('get')
->method('initialized')
->with($this->equalTo('doctrine.orm.default_entity_manager'))
->will($this->returnValue($em));
->will($this->returnValue(false));

$registry = new Registry($container, [], ['default' => 'doctrine.orm.default_entity_manager'], 'default', 'default');
$registry->reset();
Expand Down
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -40,6 +40,7 @@
"require-dev": {
"doctrine/coding-standard": "^6.0",
"doctrine/orm": "^2.6",
"ocramius/proxy-manager": "^2.1",
"phpunit/phpunit": "^7.5",
"symfony/phpunit-bridge": "^4.2",
"symfony/property-info": "^4.3.3|^5.0",
Expand Down

0 comments on commit 522c166

Please sign in to comment.