function SelectComplexTest::testDistinct
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct()
- 8.9.x core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct()
- 10 core/tests/Drupal/KernelTests/Core/Database/SelectComplexTest.php \Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct()
Tests distinct queries.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Database/ SelectComplexTest.php, line 183
Class
- SelectComplexTest
- Tests the Select query builder with more complex queries.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testDistinct() : void {
$query = $this->connection
->select('test_task');
$query->addField('test_task', 'task');
$query->orderBy('task');
$query->distinct();
$query_result = $query->execute()
->fetchAll(\PDO::FETCH_COLUMN);
$expected_result = [
'code',
'eat',
'found new band',
'perform at superbowl',
'sing',
'sleep',
];
$this->assertEquals($query_result, $expected_result, 'Returned the correct result.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.