public function QueryGroupByTest::testGroupByCountOnlyFilters in Drupal 9
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Kernel/QueryGroupByTest.php \Drupal\Tests\views\Kernel\QueryGroupByTest::testGroupByCountOnlyFilters()
- 10 core/modules/views/tests/src/Kernel/QueryGroupByTest.php \Drupal\Tests\views\Kernel\QueryGroupByTest::testGroupByCountOnlyFilters()
Tests groupby with filters.
File
- core/
modules/ views/ tests/ src/ Kernel/ QueryGroupByTest.php, line 185
Class
- QueryGroupByTest
- Tests aggregate functionality of views, for example count.
Namespace
Drupal\Tests\views\KernelCode
public function testGroupByCountOnlyFilters() {
// Check if GROUP BY and HAVING are included when a view
// doesn't display SUM, COUNT, MAX, etc. functions in SELECT statement.
for ($x = 0; $x < 10; $x++) {
$this->storage
->create([
'name' => 'name1',
])
->save();
}
$view = Views::getView('test_group_by_in_filters');
$this
->executeView($view);
$this
->assertStringContainsString('GROUP BY', (string) $view->build_info['query'], 'Make sure that GROUP BY is in the query');
$this
->assertStringContainsString('HAVING', (string) $view->build_info['query'], 'Make sure that HAVING is in the query');
}