annotate core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents af1871eacc83
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Tests\taxonomy\Functional;
Chris@0 4
Chris@0 5 /**
Chris@0 6 * Ensures that the term pager works properly.
Chris@0 7 *
Chris@0 8 * @group taxonomy
Chris@0 9 */
Chris@0 10 class TaxonomyTermPagerTest extends TaxonomyTestBase {
Chris@0 11
Chris@0 12 /**
Chris@0 13 * Modules to enable.
Chris@0 14 *
Chris@0 15 * @var array
Chris@0 16 */
Chris@0 17 public static $modules = ['taxonomy'];
Chris@0 18
Chris@0 19 /**
Chris@0 20 * Vocabulary for testing.
Chris@0 21 *
Chris@0 22 * @var \Drupal\taxonomy\VocabularyInterface
Chris@0 23 */
Chris@0 24 protected $vocabulary;
Chris@0 25
Chris@0 26 /**
Chris@0 27 * {@inheritdoc}
Chris@0 28 */
Chris@0 29 protected function setUp() {
Chris@0 30 parent::setUp();
Chris@0 31 $this->drupalLogin($this->drupalCreateUser(['administer taxonomy', 'bypass node access']));
Chris@0 32 $this->vocabulary = $this->createVocabulary();
Chris@0 33 }
Chris@0 34
Chris@0 35 /**
Chris@0 36 * Tests that the pager is displayed properly on the term overview page.
Chris@0 37 */
Chris@0 38 public function testTaxonomyTermOverviewPager() {
Chris@0 39 // Set limit to 3 terms per page.
Chris@0 40 $this->config('taxonomy.settings')
Chris@0 41 ->set('terms_per_page_admin', '3')
Chris@0 42 ->save();
Chris@0 43
Chris@0 44 // Create 3 terms.
Chris@0 45 for ($x = 1; $x <= 3; $x++) {
Chris@0 46 $this->createTerm($this->vocabulary);
Chris@0 47 }
Chris@0 48
Chris@0 49 // Get Page 1.
Chris@0 50 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
Chris@18 51 $this->assertSession()->responseNotMatches('|<nav class="pager" [^>]*>|', 'Pager is not visible on page 1');
Chris@0 52
Chris@0 53 // Create 3 more terms to show pager.
Chris@0 54 for ($x = 1; $x <= 3; $x++) {
Chris@0 55 $this->createTerm($this->vocabulary);
Chris@0 56 }
Chris@0 57
Chris@0 58 // Get Page 1.
Chris@0 59 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
Chris@0 60 $this->assertPattern('|<nav class="pager" [^>]*>|', 'Pager is visible on page 1');
Chris@0 61
Chris@0 62 // Get Page 2.
Chris@0 63 $this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 1]]);
Chris@0 64 $this->assertPattern('|<nav class="pager" [^>]*>|', 'Pager is visible on page 2');
Chris@0 65 }
Chris@0 66
Chris@0 67 }