You are here

public function ViewsAggregatorResultsTest::testPagerSettings in Views Aggregator Plus 8

Test the pager and how it works with totals.

File

tests/src/Functional/Plugin/ViewsAggregatorResultsTest.php, line 58

Class

ViewsAggregatorResultsTest
Tests the views aggregator results.

Namespace

Drupal\Tests\views_aggregator\Functional\Plugin

Code

public function testPagerSettings() {
  $this
    ->drupalGet('va-test-style-table');
  $view = View::load('va_test_style_table');
  $display =& $view
    ->getDisplay('default');

  // Enable the pager on page_1.
  $display['display_options']['pager']['type'] = 'full';
  $display['display_options']['pager']['options']['items_per_page'] = 3;
  $display['display_options']['pager']['options']['offset'] = 0;
  $display['display_options']['pager']['options']['id'] = 0;
  $display['display_options']['pager']['options']['total_pages'] = NULL;
  $view
    ->save();

  // Check the total sum of 'age' is for the page shown.
  $this
    ->drupalGet('va-test-style-table');
  $this
    ->assertFieldByXPath('//thead/tr/td', '84');

  // Enable totals to be calculated on the entire result set.
  $display =& $view
    ->getDisplay('default');
  $display['display_options']['style']['options']['column_aggregation']['totals_per_page'] = '0';
  $view
    ->save();

  // Check the total sum of 'age' is for the entire result set.
  $this
    ->drupalGet('va-test-style-table');
  $this
    ->assertFieldByXPath('//thead/tr/td', '136');
}