function ModerationStateNodeTest::testPagers

Same name in other branches
  1. 9 core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php \Drupal\Tests\content_moderation\Functional\ModerationStateNodeTest::testPagers()
  2. 8.9.x core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php \Drupal\Tests\content_moderation\Functional\ModerationStateNodeTest::testPagers()
  3. 11.x 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 140

Class

ModerationStateNodeTest
Tests general content moderation workflow for nodes.

Namespace

Drupal\Tests\content_moderation\Functional

Code

public function testPagers() : void {
    // 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']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.