outline-8.x-1.x-dev/tests/src/Functional/OutlineEntryPagerTest.php
tests/src/Functional/OutlineEntryPagerTest.php
<?php
namespace Drupal\Tests\outline\Functional;
/**
* Ensures that the entry pager works properly.
*
* @group outline
*/
class OutlineEntryPagerTest extends OutlineTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = ['outline'];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Outline for testing.
*
* @var \Drupal\outline\OutlineInterface
*/
protected $outline;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
$this->drupalLogin($this->drupalCreateUser([
'administer outline',
'bypass node access',
]));
$this->outline = $this->createOutline();
}
/**
* Tests that the pager is displayed properly on the entry overview page.
*/
public function testOutlineEntryOverviewPager() {
// Set limit to 3 entries per page.
$this->config('outline.settings')
->set('entries_per_page_admin', '3')
->save();
// Create 3 entries.
for ($x = 1; $x <= 3; $x++) {
$this->createEntry($this->outline);
}
// Get Page 1.
$this->drupalGet('admin/structure/outline/manage/' . $this->outline->id() . '/overview');
$this->assertSession()->responseNotMatches('|<nav class="pager" [^>]*>|', 'Pager is not visible on page 1');
// Create 3 more entries to show pager.
for ($x = 1; $x <= 3; $x++) {
$this->createEntry($this->outline);
}
// Ensure that pager is visible on page 1.
$this->drupalGet('admin/structure/outline/manage/' . $this->outline->id() . '/overview');
$this->assertPattern('|<nav class="pager" [^>]*>|');
// Ensure that pager is visible on page 2.
$this->drupalGet('admin/structure/outline/manage/' . $this->outline->id() . '/overview', ['query' => ['page' => 1]]);
$this->assertPattern('|<nav class="pager" [^>]*>|');
}
}
