33/**
44 * This file is part of MetaModels/core.
55 *
6- * (c) 2012-2021 The MetaModels team.
6+ * (c) 2012-2026 The MetaModels team.
77 *
88 * For the full copyright and license information, please view the LICENSE
99 * file that was distributed with this source code.
1313 * @package MetaModels/core
1414 * @author Christian Schiffler <c.schiffler@cyberspectrum.de>
1515 * @author Sven Baumann <baumann.sv@gmail.com>
16- * @copyright 2012-2021 The MetaModels team.
16+ * @author Ingolf Steinhardt <info@e-spin.de>
17+ * @copyright 2012-2026 The MetaModels team.
1718 * @license https://github.com/MetaModels/core/blob/master/LICENSE LGPL-3.0-or-later
1819 * @filesource
1920 */
2021
2122namespace MetaModels \Test ;
2223
24+ use Doctrine \DBAL \ArrayParameterType ;
2325use Doctrine \DBAL \Connection ;
2426use Doctrine \DBAL \Query \Expression \ExpressionBuilder ;
2527use Doctrine \DBAL \Query \QueryBuilder ;
@@ -99,7 +101,6 @@ public function testBuildDatabaseParameterList(): void
99101 );
100102
101103 $ reflection = new \ReflectionMethod ($ metaModel , 'buildDatabaseParameterList ' );
102- $ reflection ->setAccessible (true );
103104 self ::assertEquals ('? ' , $ reflection ->invoke ($ metaModel , [1 ]));
104105 self ::assertEquals ('?,? ' , $ reflection ->invoke ($ metaModel , [1 , 2 ]));
105106 self ::assertEquals ('?,?,?,?,?,? ' , $ reflection ->invoke ($ metaModel , [1 , 2 , 'fooo ' , 'bar ' , null , 'test ' ]));
@@ -159,7 +160,7 @@ public function testRetrieveSystemColumns(): void
159160 $ builder
160161 ->expects ($ this ->once ())
161162 ->method ('setParameter ' )
162- ->with ('values ' , [1 ], Connection:: PARAM_STR_ARRAY )
163+ ->with ('values ' , [1 ], ArrayParameterType:: STRING )
163164 ->willReturn ($ builder );
164165
165166 $ builder
@@ -278,7 +279,7 @@ public function testGetIdsFromFilterSortedByPid(): void
278279 $ builder
279280 ->expects ($ this ->once ())
280281 ->method ('setParameter ' )
281- ->with ('values ' , [4 , 3 , 2 , 1 ], Connection:: PARAM_STR_ARRAY )
282+ ->with ('values ' , [4 , 3 , 2 , 1 ], ArrayParameterType:: STRING )
282283 ->willReturn ($ builder );
283284
284285 $ builder
@@ -366,7 +367,7 @@ public function testGetIdsFromFilterSortedByPidWithCache(): void
366367 $ builder
367368 ->expects ($ this ->once ())
368369 ->method ('setParameter ' )
369- ->with ('values ' , [4 , 3 , 2 , 1 ], Connection:: PARAM_STR_ARRAY )
370+ ->with ('values ' , [4 , 3 , 2 , 1 ], ArrayParameterType:: STRING )
370371 ->willReturn ($ builder );
371372
372373 $ builder
@@ -409,7 +410,7 @@ public function testGetCountForEmptyList(): void
409410 {
410411 $ metaModel = $ this
411412 ->getMockBuilder (MetaModel::class)
412- ->onlyMethods (['getMatchingIds ' ])
413+ ->onlyMethods (['getMatchingIdsAuthoritative ' ])
413414 ->setConstructorArgs (
414415 [
415416 ['tableName ' => 'mm_test_retrieve ' ],
@@ -420,7 +421,7 @@ public function testGetCountForEmptyList(): void
420421 ->getMock ();
421422 $ metaModel
422423 ->expects (self ::once ())
423- ->method ('getMatchingIds ' )
424+ ->method ('getMatchingIdsAuthoritative ' )
424425 ->willReturn ([]);
425426
426427 /** @var MetaModel $metaModel */
@@ -433,71 +434,16 @@ public function testGetCountForEmptyList(): void
433434 public function testGetCountForNonEmptyList (): void
434435 {
435436 $ metaModel = $ this ->getMockBuilder (MetaModel::class)
436- ->onlyMethods (['getMatchingIds ' ])
437+ ->onlyMethods (['getMatchingIdsAuthoritative ' ])
437438 ->setConstructorArgs ([
438439 ['tableName ' => 'mm_test_retrieve ' ],
439440 $ this ->getMockForAbstractClass (EventDispatcherInterface::class),
440- $ this ->mockConnection (
441- (function () {
442- $ builder = $ this
443- ->getMockBuilder (QueryBuilder::class)
444- ->disableOriginalConstructor ()
445- ->getMock ();
446- $ builder
447- ->expects ($ this ->once ())
448- ->method ('select ' )
449- ->with ('COUNT(t.id) ' )
450- ->willReturn ($ builder );
451- $ builder
452- ->expects ($ this ->once ())
453- ->method ('from ' )
454- ->with ('mm_test_retrieve ' , 't ' )
455- ->willReturn ($ builder );
456-
457- $ expr = $ this
458- ->getMockBuilder (ExpressionBuilder::class)
459- ->disableOriginalConstructor ()
460- ->onlyMethods ([])
461- ->getMock ();
462-
463- $ builder
464- ->expects ($ this ->once ())
465- ->method ('expr ' )
466- ->willReturn ($ expr );
467-
468- $ builder
469- ->expects ($ this ->once ())
470- ->method ('where ' )
471- ->with ('t.id IN (:values) ' )
472- ->willReturn ($ builder );
473-
474- $ builder
475- ->expects ($ this ->once ())
476- ->method ('setParameter ' )
477- ->with ('values ' , [4 , 3 , 2 , 1 ], Connection::PARAM_STR_ARRAY )
478- ->willReturn ($ builder );
479-
480- $ result = $ this
481- ->getMockBuilder (Result::class)
482- ->disableOriginalConstructor ()
483- ->getMock ();
484- $ result
485- ->expects ($ this ->once ())
486- ->method ('fetchOne ' )
487- ->willReturn (4 );
488- $ builder
489- ->expects ($ this ->once ())
490- ->method ('executeQuery ' )
491- ->willReturn ($ result );
492-
493- return $ builder ;
494- })->__invoke ()
495- )
441+ $ this ->mockConnection ()
496442 ])
497443 ->getMock ();
498444 $ metaModel
499445 ->expects (self ::once ())
500- ->method ('getMatchingIds ' )
446+ ->method ('getMatchingIdsAuthoritative ' )
501447 ->willReturn ([4 , 3 , 2 , 1 ]);
502448
503449 self ::assertEquals (4 , $ metaModel ->getCount ($ metaModel ->getEmptyFilter ()));
0 commit comments