Skip to content

Commit 5ba4d33

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: [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 e640fae + 547c5eb commit 5ba4d33

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;
@@ -236,6 +237,15 @@ public function getTypes(string $class, string $property, array $context = []):
236237
}
237238

238239
$nullable = $metadata instanceof ClassMetadata && $metadata->isNullable($property);
240+
241+
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
242+
if (Types::BIGINT === $typeOfField && !method_exists(BigIntType::class, 'getName')) {
243+
return [
244+
new Type(Type::BUILTIN_TYPE_INT, $nullable),
245+
new Type(Type::BUILTIN_TYPE_STRING, $nullable),
246+
];
247+
}
248+
239249
$enumType = null;
240250
if (null !== $enumClass = self::getMappingValue($metadata->getFieldMapping($property), 'enumType') ?? null) {
241251
$enumType = new LegacyType(LegacyType::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;
@@ -153,10 +154,17 @@ public function testExtractEnumLegacy()
153154
*/
154155
public static function legacyTypesProvider(): array
155156
{
157+
// DBAL 4 has a special fallback strategy for BINGINT (int -> string)
158+
if (!method_exists(BigIntType::class, 'getName')) {
159+
$expectedBingIntType = [new LegacyType(LegacyType::BUILTIN_TYPE_INT), new Type(LegacyType::BUILTIN_TYPE_STRING)];
160+
} else {
161+
$expectedBingIntType = [new LegacyType(LegacyType::BUILTIN_TYPE_STRING)];
162+
}
163+
156164
return [
157165
['id', [new LegacyType(LegacyType::BUILTIN_TYPE_INT)]],
158166
['guid', [new LegacyType(LegacyType::BUILTIN_TYPE_STRING)]],
159-
['bigint', [new LegacyType(LegacyType::BUILTIN_TYPE_STRING)]],
167+
['bigint', $expectedBingIntType],
160168
['time', [new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'DateTime')]],
161169
['timeImmutable', [new LegacyType(LegacyType::BUILTIN_TYPE_OBJECT, false, 'DateTimeImmutable')]],
162170
['dateInterval', [new LegacyType(LegacyType::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
@@ -31,6 +31,7 @@
3131
use Symfony\Bridge\Doctrine\Tests\Fixtures\Dto;
3232
use Symfony\Bridge\Doctrine\Tests\Fixtures\Employee;
3333
use Symfony\Bridge\Doctrine\Tests\Fixtures\HireAnEmployee;
34+
use Symfony\Bridge\Doctrine\Tests\Fixtures\MockableRepository;
3435
use Symfony\Bridge\Doctrine\Tests\Fixtures\Person;
3536
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
3637
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdNoToStringEntity;
@@ -91,14 +92,10 @@ protected function createRegistryMock($em = null)
9192

9293
protected function createRepositoryMock()
9394
{
94-
$repository = $this->getMockBuilder(EntityRepository::class)
95+
return $this->getMockBuilder(MockableRepository::class)
9596
->disableOriginalConstructor()
96-
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName'])
97-
->addMethods(['findByCustom'])
98-
->getMock()
99-
;
100-
101-
return $repository;
97+
->onlyMethods(['find', 'findAll', 'findOneBy', 'findBy', 'getClassName', 'findByCustom'])
98+
->getMock();
10299
}
103100

104101
protected function createEntityManagerMock($repositoryMock)

0 commit comments

Comments
 (0)