You are here

public function ViewsQueryGroupByTest::testGroupByCountOnlyFilters in Views (for Drupal 7) 7.3

File

tests/views_groupby.test, line 360
Definitions of ViewsQueryGroupByTest and ViewsUiGroupbyTestCase.

Class

ViewsQueryGroupByTest
Tests aggregate functionality of views, for example count.

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);
  }
  $view = $this
    ->viewsGroupByCountViewOnlyFilters();
  $output = $view
    ->execute_display();
  $this
    ->assertTrue(strpos($view->build_info['query'], 'GROUP BY'), t('Make sure that GROUP BY is in the query'));
  $this
    ->assertTrue(strpos($view->build_info['query'], 'HAVING'), t('Make sure that HAVING is in the query'));
}