11
11
12
12
namespace Symfony \Bridge \Doctrine \Tests \Form \ChoiceList ;
13
13
14
+ use Doctrine \DBAL \ArrayParameterType ;
14
15
use Doctrine \DBAL \Connection ;
15
16
use Doctrine \DBAL \Result ;
16
17
use Doctrine \DBAL \Types \GuidType ;
19
20
use PHPUnit \Framework \TestCase ;
20
21
use Symfony \Bridge \Doctrine \Form \ChoiceList \ORMQueryBuilderLoader ;
21
22
use Symfony \Bridge \Doctrine \Tests \DoctrineTestHelper ;
23
+ use Symfony \Bridge \Doctrine \Tests \Fixtures \SingleIntIdEntity ;
24
+ use Symfony \Bridge \Doctrine \Tests \Fixtures \SingleStringIdEntity ;
22
25
use Symfony \Bridge \Doctrine \Types \UlidType ;
23
26
use Symfony \Bridge \Doctrine \Types \UuidType ;
24
27
use Symfony \Component \Form \Exception \TransformationFailedException ;
@@ -35,12 +38,12 @@ protected function tearDown(): void
35
38
36
39
public function testIdentifierTypeIsStringArray ()
37
40
{
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 );
39
42
}
40
43
41
44
public function testIdentifierTypeIsIntegerArray ()
42
45
{
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 );
44
47
}
45
48
46
49
protected function checkIdentifierType ($ classname , $ expectedType )
@@ -90,7 +93,7 @@ public function testFilterNonIntegerValues()
90
93
91
94
$ query ->expects ($ this ->once ())
92
95
->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 )
94
97
->willReturn ($ query );
95
98
96
99
$ qb = $ this ->getMockBuilder (\Doctrine \ORM \QueryBuilder::class)
@@ -126,7 +129,7 @@ public function testFilterEmptyUuids($entityClass)
126
129
127
130
$ query ->expects ($ this ->once ())
128
131
->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 )
130
133
->willReturn ($ query );
131
134
132
135
$ qb = $ this ->getMockBuilder (\Doctrine \ORM \QueryBuilder::class)
@@ -171,7 +174,7 @@ public function testFilterUid($entityClass)
171
174
172
175
$ query ->expects ($ this ->once ())
173
176
->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 )
175
178
->willReturn ($ query );
176
179
177
180
$ qb = $ this ->getMockBuilder (\Doctrine \ORM \QueryBuilder::class)
@@ -239,7 +242,7 @@ public function testEmbeddedIdentifierName()
239
242
240
243
$ query ->expects ($ this ->once ())
241
244
->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 )
243
246
->willReturn ($ query );
244
247
245
248
$ qb = $ this ->getMockBuilder (\Doctrine \ORM \QueryBuilder::class)
0 commit comments