diff --git a/core/modules/system/src/Tests/Pager/PagerTest.php b/core/modules/system/src/Tests/Pager/PagerTest.php index d25dd9a..b20e974 100644 --- a/core/modules/system/src/Tests/Pager/PagerTest.php +++ b/core/modules/system/src/Tests/Pager/PagerTest.php @@ -108,6 +108,10 @@ protected function assertPagerItems($current_page) { // Make current page 1-based. $current_page++; + // We remove elements from the $elements array in the following code, so + // we store the total number of pages for verifying the "last" link. + $total_pages = count($elements); + // Extract first/previous and next/last items. // first/previous only exist, if the current page is not the first. if ($current_page > 1) { @@ -118,7 +122,6 @@ protected function assertPagerItems($current_page) { if ($current_page != count($elements)) { $last = array_pop($elements); $next = array_pop($elements); - $total_pages = count($elements); } // Verify items and links to pages.