Skip to content

Commit 547c5eb

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [Serializer] Improve exception message in UnwrappingDenormalizer [PropertyInfo] Update DoctrineExtractor for new DBAL 4 BIGINT type Update security.nl.xlf [Validator] IBAN Check digits should always between 2 and 98 [Security] Populate translations for trans-unit 20 add missing plural translation messages filter out empty HTTP header parts [String] Fix folded in compat mode Remove calls to `getMockForAbstractClass()` [ErrorHandler] Do not call xdebug_get_function_stack() with xdebug >= 3.0 when not in develop mode [Serializer] Fix type for missing property add test for JSON response with null as content [Filesystem] Fix dumpFile `stat failed` error hitting custom handler Return false in isTtySupported() when open_basedir restrictions prevent access to /dev/tty. Remove calls to `TestCase::iniSet()` and calls to deprecated methods of `MockBuilder` [PhpUnitBridge] Fix `DeprecationErrorHandler` with PhpUnit 10
2 parents 5594233 + 04737c5 commit 547c5eb

File tree

5 files changed

+47
-14
lines changed

5 files changed

+47
-14
lines changed

PropertyInfo/DoctrineExtractor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\PropertyInfo;
1313

1414
use Doctrine\Common\Collections\Collection;
15+
use Doctrine\DBAL\Types\BigIntType;
1516
use Doctrine\DBAL\Types\Types;
1617
use Doctrine\ORM\EntityManagerInterface;
1718
use Doctrine\ORM\Mapping\AssociationMapping;
@@ -132,6 +133,15 @@ public function getTypes(string $class, string $property, array $context = []):
132133
}
133134

134135
$nullable = $metadata instanceof ClassMetadata && $metadata->isNullable($property);
136+
137+
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
138+
if (Types::BIGINT === $typeOfField && !method_exists(BigIntType::class, 'getName')) {
139+
return [
140+
new Type(Type::BUILTIN_TYPE_INT, $nullable),
141+
new Type(Type::BUILTIN_TYPE_STRING, $nullable),
142+
];
143+
}
144+
135145
$enumType = null;
136146
if (null !== $enumClass = self::getMappingValue($metadata->getFieldMapping($property), 'enumType') ?? null) {
137147
$enumType = new Type(Type::BUILTIN_TYPE_OBJECT, $nullable, $enumClass);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
13+
14+
use Doctrine\ORM\EntityRepository;
15+
16+
class MockableRepository extends EntityRepository
17+
{
18+
public function findByCustom()
19+
{
20+
}
21+
}

Tests/PropertyInfo/DoctrineExtractorTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Doctrine\Common\EventManager;
1616
use Doctrine\DBAL\DriverManager;
1717
use Doctrine\DBAL\Schema\DefaultSchemaManagerFactory;
18+
use Doctrine\DBAL\Types\BigIntType;
1819
use Doctrine\DBAL\Types\Type as DBALType;
1920
use Doctrine\ORM\EntityManager;
2021
use Doctrine\ORM\Mapping\Driver\AttributeDriver;
@@ -141,10 +142,17 @@ public function testExtractEnum()
141142

142143
public static function typesProvider(): array
143144
{
145+
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
146+
if (!method_exists(BigIntType::class, 'getName')) {
147+
$expectedBingIntType = [new Type(Type::BUILTIN_TYPE_INT), new Type(Type::BUILTIN_TYPE_STRING)];
148+
} else {
149+
$expectedBingIntType = [new Type(Type::BUILTIN_TYPE_STRING)];
150+
}
151+
144152
return [
145153
['id', [new Type(Type::BUILTIN_TYPE_INT)]],
146154
['guid', [new Type(Type::BUILTIN_TYPE_STRING)]],
147-
['bigint', [new Type(Type::BUILTIN_TYPE_STRING)]],
155+
['bigint', $expectedBingIntType],
148156
['time', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTime')]],
149157
['timeImmutable', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable')]],
150158
['dateInterval', [new Type(Type::BUILTIN_TYPE_OBJECT, false, 'DateInterval')]],

Tests/Security/User/EntityUserProviderTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,11 @@ private function getManager($em, $name = null)
236236

237237
private function getObjectManager($repository)
238238
{
239-
$em = $this->getMockBuilder(ObjectManager::class)
240-
->onlyMethods(['getClassMetadata', 'getRepository'])
241-
->getMockForAbstractClass();
242-
$em->expects($this->any())
243-
->method('getRepository')
239+
$objectManager = $this->createMock(ObjectManager::class);
240+
$objectManager->method('getRepository')
244241
->willReturn($repository);
245242

246-
return $em;
243+
return $objectManager;
247244
}
248245

249246
private function createSchema($em)

Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNameEntity;
2929
use Symfony\Bridge\Doctrine\Tests\Fixtures\DoubleNullableNameEntity;
3030
use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee;
31+
use Symfony\Bridge\Doctrine\Tests\Fixtures\MockableRepository;
3132
use Symfony\Bridge\Doctrine\Tests\Fixtures\Person;
3233
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
3334
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
@@ -85,14 +86,10 @@ protected function createRegistryMock($em = null)
8586

8687
protected function createRepositoryMock()
8788
{
88-
$repository = $this->getMockBuilder(EntityRepository::class)
89+
return $this->getMockBuilder(MockableRepository::class)
8990
->disableOriginalConstructor()
90-
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName'])
91-
->addMethods(['findByCustom'])
92-
->getMock()
93-
;
94-
95-
return $repository;
91+
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName', 'findByCustom'])
92+
->getMock();
9693
}
9794

9895
protected function createEntityManagerMock($repositoryMock)

0 commit comments

Comments
 (0)