Skip to content
This repository has been archived by the owner on Feb 24, 2023. It is now read-only.

Commit

Permalink
bug #698 Added missing changes for doctrine/persistence. (Michał Jusi…
Browse files Browse the repository at this point in the history
…ęga)

This PR was squashed before being merged into the 5.6.x-dev branch.

Discussion
----------

Added missing changes for doctrine/persistence.

Not everything has been changed in #691

Commits
-------

2906468 Added missing changes for doctrine/persistence.
  • Loading branch information
fabpot committed Aug 25, 2020
2 parents ced361d + 2906468 commit 430d14c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 47 deletions.
11 changes: 1 addition & 10 deletions src/EventListener/ControllerListener.php
Expand Up @@ -12,7 +12,6 @@
namespace Sensio\Bundle\FrameworkExtraBundle\EventListener;

use Doctrine\Common\Annotations\Reader;
use Doctrine\Common\Persistence\Proxy as LegacyProxy;
use Doctrine\Persistence\Proxy;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -70,7 +69,7 @@ public function onKernelController(KernelEvent $event)
} else {
if (\is_array($classConfigurations[$key])) {
if (!\is_array($methodConfigurations[$key])) {
throw new \UnexpectedValueException('Configurations should both be an array or both not be an array');
throw new \UnexpectedValueException('Configurations should both be an array or both not be an array.');
}
$configurations[$key] = array_merge($classConfigurations[$key], $methodConfigurations[$key]);
} else {
Expand Down Expand Up @@ -124,14 +123,6 @@ private static function getRealClass(string $class): string
return substr($class, $pos + Proxy::MARKER_LENGTH + 2);
}

if (class_exists(LegacyProxy::class)) {
if (false === $pos = strrpos($class, '\\'.LegacyProxy::MARKER.'\\')) {
return $class;
}

return substr($class, $pos + LegacyProxy::MARKER_LENGTH + 2);
}

return $class;
}
}
2 changes: 1 addition & 1 deletion src/Templating/TemplateGuesser.php
Expand Up @@ -11,7 +11,7 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Templating;

use Doctrine\Common\Persistence\Proxy;
use Doctrine\Persistence\Proxy;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\KernelInterface;

Expand Down
72 changes: 36 additions & 36 deletions tests/Request/ParamConverter/DoctrineParamConverterTest.php
Expand Up @@ -11,8 +11,8 @@

namespace Sensio\Bundle\FrameworkExtraBundle\Tests\Request\ParamConverter;

use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\DBAL\Types\ConversionException;
use Doctrine\Persistence\ManagerRegistry;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\DoctrineParamConverter;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
Expand All @@ -38,7 +38,7 @@ class DoctrineParamConverterTest extends \PHPUnit\Framework\TestCase

protected function setUp(): void
{
$this->registry = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
$this->registry = $this->getMockBuilder('Doctrine\Persistence\ManagerRegistry')->getMock();
$this->language = $this->getMockBuilder('Symfony\Component\ExpressionLanguage\ExpressionLanguage')->getMock();
$this->converter = new DoctrineParamConverter($this->registry, $this->language);
}
Expand Down Expand Up @@ -82,7 +82,7 @@ public function testApplyWithNoIdAndData()

$request = new Request();
$config = $this->createConfiguration(null, []);
$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();

$this->converter->apply($request, $config);
}
Expand All @@ -91,7 +91,7 @@ public function testApplyWithNoIdAndDataOptional()
{
$request = new Request();
$config = $this->createConfiguration(null, [], 'arg', true);
$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();

$ret = $this->converter->apply($request, $config);

Expand All @@ -105,8 +105,8 @@ public function testApplyWithStripNulls()
$request->attributes->set('arg', null);
$config = $this->createConfiguration('stdClass', ['mapping' => ['arg' => 'arg'], 'strip_null' => true], 'arg', true);

$classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$classMetadata = $this->getMockBuilder('Doctrine\Persistence\Mapping\ClassMetadata')->getMock();
$manager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$manager->expects($this->once())
->method('getClassMetadata')
->with('stdClass')
Expand Down Expand Up @@ -140,8 +140,8 @@ public function testApplyWithId($id)

$config = $this->createConfiguration('stdClass', ['id' => 'id'], 'arg');

$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$manager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();
$this->registry->expects($this->once())
->method('getManagerForClass')
->with('stdClass')
Expand Down Expand Up @@ -172,8 +172,8 @@ public function testApplyWithConversionFailedException()

$config = $this->createConfiguration('stdClass', ['id' => 'id'], 'arg');

$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$manager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();
$this->registry->expects($this->once())
->method('getManagerForClass')
->with('stdClass')
Expand Down Expand Up @@ -223,14 +223,14 @@ public function testApplyGuessOptional()

$config = $this->createConfiguration('stdClass', [], 'arg', null);

$classMetadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$classMetadata = $this->getMockBuilder('Doctrine\Persistence\Mapping\ClassMetadata')->getMock();
$manager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$manager->expects($this->once())
->method('getClassMetadata')
->with('stdClass')
->willReturn($classMetadata);

$objectRepository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();
$this->registry->expects($this->once())
->method('getManagerForClass')
->with('stdClass')
Expand Down Expand Up @@ -259,9 +259,9 @@ public function testApplyWithMappingAndExclude()
'arg'
);

$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$metadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$repository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$manager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$metadata = $this->getMockBuilder('Doctrine\Persistence\Mapping\ClassMetadata')->getMock();
$repository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();

$this->registry->expects($this->once())
->method('getManagerForClass')
Expand Down Expand Up @@ -307,8 +307,8 @@ public function testApplyWithRepositoryMethod()
'arg'
);

$objectRepository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();
$manager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$manager->expects($this->once())
->method('getRepository')
->with('stdClass')
Expand Down Expand Up @@ -341,9 +341,9 @@ public function testApplyWithRepositoryMethodAndMapping()
'arg'
);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$metadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();
$metadata = $this->getMockBuilder('Doctrine\Persistence\Mapping\ClassMetadata')->getMock();

$objectManager->expects($this->once())
->method('getRepository')
Expand Down Expand Up @@ -396,9 +396,9 @@ public function testApplyWithRepositoryMethodAndMapMethodSignature()
'arg'
);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectRepository = new TestUserRepository();
$metadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$metadata = $this->getMockBuilder('Doctrine\Persistence\Mapping\ClassMetadata')->getMock();

$objectManager->expects($this->once())
->method('getRepository')
Expand Down Expand Up @@ -441,9 +441,9 @@ public function testApplyWithRepositoryMethodAndMapMethodSignatureException()
'arg'
);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectRepository = new TestUserRepository();
$metadata = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadata')->getMock();
$metadata = $this->getMockBuilder('Doctrine\Persistence\Mapping\ClassMetadata')->getMock();

$objectManager->expects($this->once())
->method('getRepository')
Expand All @@ -464,13 +464,13 @@ public function testApplyWithRepositoryMethodAndMapMethodSignatureException()
public function testSupports()
{
$config = $this->createConfiguration('stdClass', []);
$metadataFactory = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory')->getMock();
$metadataFactory = $this->getMockBuilder('Doctrine\Persistence\Mapping\ClassMetadataFactory')->getMock();
$metadataFactory->expects($this->once())
->method('isTransient')
->with($this->equalTo('stdClass'))
->willReturn(false);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectManager->expects($this->once())
->method('getMetadataFactory')
->willReturn($metadataFactory);
Expand All @@ -492,13 +492,13 @@ public function testSupports()
public function testSupportsWithConfiguredEntityManager()
{
$config = $this->createConfiguration('stdClass', ['entity_manager' => 'foo']);
$metadataFactory = $this->getMockBuilder('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory')->getMock();
$metadataFactory = $this->getMockBuilder('Doctrine\Persistence\Mapping\ClassMetadataFactory')->getMock();
$metadataFactory->expects($this->once())
->method('isTransient')
->with($this->equalTo('stdClass'))
->willReturn(false);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectManager->expects($this->once())
->method('getMetadataFactory')
->willReturn($metadataFactory);
Expand All @@ -521,7 +521,7 @@ public function testSupportsWithDifferentConfiguration()
{
$config = $this->createConfiguration('DateTime', ['format' => \DateTime::ISO8601]);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectManager->expects($this->never())
->method('getMetadataFactory');

Expand Down Expand Up @@ -567,8 +567,8 @@ public function testExpressionFailureReturns404()
'arg1'
);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();

$objectManager->expects($this->once())
->method('getRepository')
Expand Down Expand Up @@ -601,8 +601,8 @@ public function testExpressionMapsToArgument()
'arg1'
);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();

$objectManager->expects($this->once())
->method('getRepository')
Expand Down Expand Up @@ -642,8 +642,8 @@ public function testExpressionSyntaxErrorThrowsException()
'arg1'
);

$objectManager = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Common\Persistence\ObjectRepository')->getMock();
$objectManager = $this->getMockBuilder('Doctrine\Persistence\ObjectManager')->getMock();
$objectRepository = $this->getMockBuilder('Doctrine\Persistence\ObjectRepository')->getMock();

$objectManager->expects($this->once())
->method('getRepository')
Expand Down

0 comments on commit 430d14c

Please sign in to comment.