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