From 29bc6cc9551214c92d87b6f30ab9f7bc76835833 Mon Sep 17 00:00:00 2001 From: Matthias Pigulla Date: Tue, 14 Feb 2023 08:42:39 +0100 Subject: [PATCH] Write a test in a more specific way MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... so we can be sure that in fact the second result has a different size. Co-authored-by: Luís Cobucci --- .../Tests/ORM/Functional/PaginationTest.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php index d352ae1ed48..c4fa3296d0b 100644 --- a/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/PaginationTest.php @@ -674,18 +674,19 @@ public function testDifferentResultLengthsDoNotRequireExtraQueryCacheEntries(): $query->setMaxResults(10); $query->setParameter('id', 1); - $paginator = new Paginator($query); - $paginator->getIterator(); // exercise the Paginator + $paginator = new Paginator($query); + $initialResult = iterator_to_array($paginator->getIterator()); // exercise the Paginator + self::assertCount(9, $initialResult); - $initialCount = count(self::$queryCache->getValues()); + $initialQueryCount = count(self::$queryCache->getValues()); - $query->setParameter('id', 2); + $query->setParameter('id', $initialResult[1]->id); // skip the first result element $paginator = new Paginator($query); - $paginator->getIterator(); // exercise the Paginator again, with a smaller result set + self::assertCount(8, $paginator->getIterator()); // exercise the Paginator again, with a smaller result set $newCount = count(self::$queryCache->getValues()); - self::assertSame($initialCount, $newCount); + self::assertSame($initialQueryCount, $newCount); } public function populate(): void