You are here

public function ViewsAggregatorResultsTest::testTotalsSettings in Views Aggregator Plus 8

Test the positioning of the column aggregation results (totals).

File

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

Class

ViewsAggregatorResultsTest
Tests the views aggregator results.

Namespace

Drupal\Tests\views_aggregator\Functional\Plugin

Code

public function testTotalsSettings() {
  $this
    ->drupalGet('va-test-style-table');

  // The results should be in both table header and footer.
  $this
    ->assertFieldByXPath('//thead/tr/td', 'TOTAL');
  $this
    ->assertFieldByXPath('//tfoot/tr/td', 'TOTAL');

  // Set the totals row in the table header only.
  $view = View::load('va_test_style_table');
  $display =& $view
    ->getDisplay('default');
  $display['display_options']['style']['options']['column_aggregation']['totals_row_position']['1'] = '1';
  $display['display_options']['style']['options']['column_aggregation']['totals_row_position']['2'] = '0';
  $view
    ->save();

  // Ensure the 'TOTAL' label appears only in the table header.
  $this
    ->drupalGet('va-test-style-table');
  $this
    ->assertFieldByXPath('//thead/tr/td', 'TOTAL');
  $this
    ->assertNoFieldByXPath('//tfoot/tr/td', 'TOTAL');

  // Set the totals row in the table header only.
  $display =& $view
    ->getDisplay('default');
  $display['display_options']['style']['options']['column_aggregation']['totals_row_position']['1'] = '0';
  $display['display_options']['style']['options']['column_aggregation']['totals_row_position']['2'] = '2';
  $view
    ->save();

  // Ensure the 'TOTAL' label appears only in the table footer.
  $this
    ->drupalGet('va-test-style-table');
  $this
    ->assertNoFieldByXPath('//thead/tr/td', 'TOTAL');
  $this
    ->assertFieldByXPath('//tfoot/tr/td', 'TOTAL');
}