Skip to content

Commit 1c2651f

Browse files
[Cache] Fix DBAL deprecations and stop using NUL chars in tags prefix
1 parent 708e9a3 commit 1c2651f

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Tests/Form/ChoiceList/ORMQueryBuilderLoaderTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Bridge\Doctrine\Tests\Form\ChoiceList;
1313

14+
use Doctrine\DBAL\ArrayParameterType;
1415
use Doctrine\DBAL\Connection;
1516
use Doctrine\DBAL\Result;
1617
use Doctrine\DBAL\Types\GuidType;
@@ -19,6 +20,8 @@
1920
use PHPUnit\Framework\TestCase;
2021
use Symfony\Bridge\Doctrine\Form\ChoiceList\ORMQueryBuilderLoader;
2122
use Symfony\Bridge\Doctrine\Tests\DoctrineTestHelper;
23+
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity;
24+
use Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity;
2225
use Symfony\Bridge\Doctrine\Types\UlidType;
2326
use Symfony\Bridge\Doctrine\Types\UuidType;
2427
use Symfony\Component\Form\Exception\TransformationFailedException;
@@ -35,12 +38,12 @@ protected function tearDown(): void
3538

3639
public function testIdentifierTypeIsStringArray()
3740
{
38-
$this->checkIdentifierType('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleStringIdEntity', Connection::PARAM_STR_ARRAY);
41+
$this->checkIdentifierType(SingleStringIdEntity::class, class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY);
3942
}
4043

4144
public function testIdentifierTypeIsIntegerArray()
4245
{
43-
$this->checkIdentifierType('Symfony\Bridge\Doctrine\Tests\Fixtures\SingleIntIdEntity', Connection::PARAM_INT_ARRAY);
46+
$this->checkIdentifierType(SingleIntIdEntity::class, class_exists(ArrayParameterType::class) ? ArrayParameterType::INTEGER : Connection::PARAM_INT_ARRAY);
4447
}
4548

4649
protected function checkIdentifierType($classname, $expectedType)
@@ -90,7 +93,7 @@ public function testFilterNonIntegerValues()
9093

9194
$query->expects($this->once())
9295
->method('setParameter')
93-
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2, 3, '9223372036854775808'], Connection::PARAM_INT_ARRAY)
96+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [1, 2, 3, '9223372036854775808'], class_exists(ArrayParameterType::class) ? ArrayParameterType::INTEGER : Connection::PARAM_INT_ARRAY)
9497
->willReturn($query);
9598

9699
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
@@ -126,7 +129,7 @@ public function testFilterEmptyUuids($entityClass)
126129

127130
$query->expects($this->once())
128131
->method('setParameter')
129-
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'], Connection::PARAM_STR_ARRAY)
132+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', ['71c5fd46-3f16-4abb-bad7-90ac1e654a2d', 'b98e8e11-2897-44df-ad24-d2627eb7f499'], class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY)
130133
->willReturn($query);
131134

132135
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
@@ -171,7 +174,7 @@ public function testFilterUid($entityClass)
171174

172175
$query->expects($this->once())
173176
->method('setParameter')
174-
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [Uuid::fromString('71c5fd46-3f16-4abb-bad7-90ac1e654a2d')->toBinary(), Uuid::fromString('b98e8e11-2897-44df-ad24-d2627eb7f499')->toBinary()], Connection::PARAM_STR_ARRAY)
177+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id', [Uuid::fromString('71c5fd46-3f16-4abb-bad7-90ac1e654a2d')->toBinary(), Uuid::fromString('b98e8e11-2897-44df-ad24-d2627eb7f499')->toBinary()], class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY)
175178
->willReturn($query);
176179

177180
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)
@@ -239,7 +242,7 @@ public function testEmbeddedIdentifierName()
239242

240243
$query->expects($this->once())
241244
->method('setParameter')
242-
->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', [1, 2, 3], Connection::PARAM_INT_ARRAY)
245+
->with('ORMQueryBuilderLoader_getEntitiesByIds_id_value', [1, 2, 3], class_exists(ArrayParameterType::class) ? ArrayParameterType::INTEGER : Connection::PARAM_INT_ARRAY)
243246
->willReturn($query);
244247

245248
$qb = $this->getMockBuilder(\Doctrine\ORM\QueryBuilder::class)

0 commit comments

Comments
 (0)