function TaxonomyTermPagerTest::testTaxonomyTermOverviewTermLoad
Same name in other branches
- 11.x core/modules/taxonomy/tests/src/Functional/TaxonomyTermPagerTest.php \Drupal\Tests\taxonomy\Functional\TaxonomyTermPagerTest::testTaxonomyTermOverviewTermLoad()
Tests that overview page only loads the necessary terms.
File
-
core/
modules/ taxonomy/ tests/ src/ Functional/ TaxonomyTermPagerTest.php, line 79
Class
- TaxonomyTermPagerTest
- Ensures that the term pager works properly.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testTaxonomyTermOverviewTermLoad() : void {
// Set limit to 3 terms per page.
$this->config('taxonomy.settings')
->set('terms_per_page_admin', '3')
->save();
$state = $this->container
->get('state');
// Create 5 terms.
for ($x = 0; $x <= 10; $x++) {
$this->createTerm($this->vocabulary, [
'weight' => $x,
]);
}
// Check the overview page.
$state->set('taxonomy_test_taxonomy_term_load', []);
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
->id() . '/overview');
$loaded_terms = $state->get('taxonomy_test_taxonomy_term_load');
$this->assertCount(4, $loaded_terms);
// Check the overview page for submit callback.
$state->set('taxonomy_test_taxonomy_term_load', []);
$this->submitForm([], 'Save');
$loaded_terms = $state->get('taxonomy_test_taxonomy_term_load');
$this->assertCount(4, $loaded_terms);
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
->id() . '/overview', [
'query' => [
'page' => 2,
],
]);
$state->set('taxonomy_test_taxonomy_term_load', []);
$this->submitForm([], 'Save');
$loaded_terms = $state->get('taxonomy_test_taxonomy_term_load');
$this->assertCount(4, $loaded_terms);
// Adding a new term with weight < 0 implies that all root terms are updated.
$this->createTerm($this->vocabulary, [
'weight' => -1,
]);
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary
->id() . '/overview', [
'query' => [
'page' => 2,
],
]);
$state->set('taxonomy_test_taxonomy_term_load', []);
$this->submitForm([], 'Save');
$loaded_terms = $state->get('taxonomy_test_taxonomy_term_load');
$this->assertCount(12, $loaded_terms);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.