Skip to content

Commit

Permalink
Write a test in a more specific way
Browse files Browse the repository at this point in the history
... so we can be sure that in fact the second result has a different size.

Co-authored-by: Luís Cobucci <[email protected]>
  • Loading branch information
mpdude and lcobucci committed Feb 14, 2023
1 parent 660197e commit 29bc6cc
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions tests/Doctrine/Tests/ORM/Functional/PaginationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 29bc6cc

Please sign in to comment.