function PagerManagerTest::testGlobalsSafety
@group legacy @expectedDeprecation Global variable $pager_page_array is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Pager\PagerManagerInterface instead. See https://www.drupal.org/node/2779457 @expectedDeprecation Global variable $pager_total_items is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Pager\PagerManagerInterface instead. See https://www.drupal.org/node/2779457 @expectedDeprecation Global variable $pager_total is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Pager\PagerManagerInterface instead. See https://www.drupal.org/node/2779457 @expectedDeprecation Global variable $pager_limits is deprecated in drupal:8.8.0 and is removed in drupal:9.0.0. Use \Drupal\Core\Pager\PagerManagerInterface instead. See https://www.drupal.org/node/2779457
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Pager/ PagerManagerTest.php, line 71
Class
- PagerManagerTest
- @group Pager
Namespace
Drupal\KernelTests\Core\PagerCode
public function testGlobalsSafety() {
/* @var $pager_manager \Drupal\Core\Pager\PagerManagerInterface */
$pager_manager = $this->container
->get('pager.manager');
$pager_manager->createPager(30, 10);
$pager_globals = [
'pager_page_array',
'pager_total_items',
'pager_total',
'pager_limits',
];
// Check globals were set.
foreach ($pager_globals as $pager_global) {
$this->assertTrue(isset($GLOBALS[$pager_global]));
}
$this->assertEquals(0, $GLOBALS['pager_page_array'][0]);
$this->assertEquals(30, $GLOBALS['pager_total_items'][0]);
$this->assertEquals(3, $GLOBALS['pager_total'][0]);
$this->assertEquals(10, $GLOBALS['pager_limits'][0]);
// Assert array is iterable.
foreach ($GLOBALS['pager_total_items'] as $pager_id => $total_items) {
// We only have one pager.
$this->assertEquals(0, $pager_id);
$this->assertEquals(30, $total_items);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.