You are here

public function TaxonomyTermPagerTest::testTaxonomyTermOverviewPager in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/Tests/TaxonomyTermPagerTest.php \Drupal\taxonomy\Tests\TaxonomyTermPagerTest::testTaxonomyTermOverviewPager()

Tests that the pager is displayed properly on the term overview page.

File

core/modules/taxonomy/src/Tests/TaxonomyTermPagerTest.php, line 43
Contains \Drupal\taxonomy\Tests\TaxonomyTermPagerTest.

Class

TaxonomyTermPagerTest
Ensures that the term pager works properly.

Namespace

Drupal\taxonomy\Tests

Code

public function testTaxonomyTermOverviewPager() {

  // Set limit to 3 terms per page.
  $this
    ->config('taxonomy.settings')
    ->set('terms_per_page_admin', '3')
    ->save();

  // Create 3 terms.
  for ($x = 1; $x <= 3; $x++) {
    $this
      ->createTerm($this->vocabulary);
  }

  // Get Page 1.
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/overview');
  $this
    ->assertNoPattern('|<nav class="pager" [^>]*>|', 'Pager is not visible on page 1');

  // Create 3 more terms to show pager.
  for ($x = 1; $x <= 3; $x++) {
    $this
      ->createTerm($this->vocabulary);
  }

  // Get Page 1.
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/overview');
  $this
    ->assertPattern('|<nav class="pager" [^>]*>|', 'Pager is visible on page 1');

  // Get Page 2.
  $this
    ->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
    ->id() . '/overview', [
    'query' => [
      'page' => 1,
    ],
  ]);
  $this
    ->assertPattern('|<nav class="pager" [^>]*>|', 'Pager is visible on page 2');
}