You are here

public function ModerationStateNodeTest::testPagers in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php \Drupal\Tests\content_moderation\Functional\ModerationStateNodeTest::testPagers()

Tests pagers aren't broken by content_moderation.

File

core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php, line 137

Class

ModerationStateNodeTest
Tests general content moderation workflow for nodes.

Namespace

Drupal\Tests\content_moderation\Functional

Code

public function testPagers() {

  // Create 51 nodes to force the pager.
  foreach (range(1, 51) as $delta) {
    Node::create([
      'type' => 'moderated_content',
      'uid' => $this->adminUser
        ->id(),
      'title' => 'Node ' . $delta,
      'status' => 1,
      'moderation_state' => 'published',
    ])
      ->save();
  }
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/content');
  $element = $this
    ->cssSelect('nav.pager li.is-active a');
  $url = $element[0]
    ->getAttribute('href');
  $query = [];
  parse_str(parse_url($url, PHP_URL_QUERY), $query);
  $this
    ->assertEquals(0, $query['page']);
}