public function QueryGroupByTest::testAggregateCount in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/views/src/Tests/QueryGroupByTest.php \Drupal\views\Tests\QueryGroupByTest::testAggregateCount()
Tests aggregate count feature.
File
- core/
modules/ views/ src/ Tests/ QueryGroupByTest.php, line 63 - Contains \Drupal\views\Tests\QueryGroupByTest.
Class
- QueryGroupByTest
- Tests aggregate functionality of views, for example count.
Namespace
Drupal\views\TestsCode
public function testAggregateCount() {
$this
->setupTestEntities();
$view = Views::getView('test_aggregate_count');
$this
->executeView($view);
$this
->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
$types = array();
foreach ($view->result as $item) {
// num_records is a alias for id.
$types[$item->entity_test_name] = $item->num_records;
}
$this
->assertEqual($types['name1'], 4, 'Groupby the name: name1 returned the expected amount of results.');
$this
->assertEqual($types['name2'], 3, 'Groupby the name: name2 returned the expected amount of results.');
}