function PreprocessPagerTest::testQuantitySet

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/src/Unit/Pager/PreprocessPagerTest.php \Drupal\Tests\system\Unit\Pager\PreprocessPagerTest::testQuantitySet()

Tests template_preprocess_pager() when a #quantity value is passed.

@covers ::template_preprocess_pager

File

core/modules/system/tests/src/Unit/Pager/PreprocessPagerTest.php, line 76

Class

PreprocessPagerTest
Tests pager preprocessing.

Namespace

Drupal\Tests\system\Unit\Pager

Code

public function testQuantitySet() : void {
  require_once $this->root . '/core/includes/theme.inc';
  $variables = [
    'pager' => [
      '#element' => '2',
      '#parameters' => [],
      '#quantity' => '2',
      '#route_name' => '',
      '#tags' => '',
    ],
  ];
  template_preprocess_pager($variables);
  $this->assertEquals([
    'first',
    'previous',
    'pages',
  ], array_keys($variables['items']));
  /** @var \Drupal\Core\Template\AttributeString $attribute */
  $attribute = $variables['items']['pages']['2']['attributes']->offsetGet('aria-current');
  $this->assertInstanceOf(AttributeString::class, $attribute);
  $this->assertEquals('page', $attribute->value());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.