function ExposedFormTest::testExposedFilterPagination

Same name and namespace in other branches
  1. 8.9.x core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testExposedFilterPagination()
  2. 10 core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testExposedFilterPagination()
  3. 11.x core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php \Drupal\Tests\views\Functional\Plugin\ExposedFormTest::testExposedFilterPagination()

Tests the exposed form with a pager.

File

core/modules/views/tests/src/Functional/Plugin/ExposedFormTest.php, line 469

Class

ExposedFormTest
Tests exposed forms functionality.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function testExposedFilterPagination() {
    $this->drupalCreateContentType([
        'type' => 'post',
    ]);
    // Create some random nodes.
    for ($i = 0; $i < 5; $i++) {
        $this->drupalCreateNode([
            'type' => 'post',
        ]);
    }
    $this->drupalGet('test_exposed_form_pager');
    $this->getSession()
        ->getPage()
        ->fillField('type[]', 'post');
    $this->getSession()
        ->getPage()
        ->fillField('created[min]', '-1 month');
    $this->getSession()
        ->getPage()
        ->fillField('created[max]', '+1 month');
    // Ensure the filters can be applied.
    $this->getSession()
        ->getPage()
        ->pressButton('Apply');
    $this->assertTrue($this->assertSession()
        ->optionExists('type[]', 'post')
        ->isSelected());
    $this->assertSession()
        ->fieldValueEquals('created[min]', '-1 month');
    $this->assertSession()
        ->fieldValueEquals('created[max]', '+1 month');
    // Ensure the filters are still applied after pressing next.
    $this->clickLink('Next ›');
    $this->assertTrue($this->assertSession()
        ->optionExists('type[]', 'post')
        ->isSelected());
    $this->assertSession()
        ->fieldValueEquals('created[min]', '-1 month');
    $this->assertSession()
        ->fieldValueEquals('created[max]', '+1 month');
}

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