You are here

public function QueryGroupByTest::testGroupByCountOnlyFilters in Views (for Drupal 7) 8.3

File

lib/Drupal/views/Tests/QueryGroupByTest.php, line 123
Definition of Drupal\views\Tests\QueryGroupByTest.

Class

QueryGroupByTest
Tests aggregate functionality of views, for example count.

Namespace

Drupal\views\Tests

Code

public function testGroupByCountOnlyFilters() {

  // Check if GROUP BY and HAVING are included when a view
  // Doesn't display SUM, COUNT, MAX... functions in SELECT statment
  $type1 = $this
    ->drupalCreateContentType();
  $node_1 = array(
    'type' => $type1->type,
  );
  for ($x = 0; $x < 10; $x++) {
    $this
      ->drupalCreateNode($node_1);
  }
  $this
    ->executeView($this->view);
  $this
    ->assertTrue(strpos($this->view->build_info['query'], 'GROUP BY'), t('Make sure that GROUP BY is in the query'));
  $this
    ->assertTrue(strpos($this->view->build_info['query'], 'HAVING'), t('Make sure that HAVING is in the query'));
}