Change SelectComplexTest::testDistinct to test the distinct values not the count

Created on 6 September 2016, over 8 years ago
Updated 20 March 2023, almost 2 years ago

Problem/Motivation

Drupal\KernelTests\Core\Database\SelectComplexTest has to tests that are exactly the same (testDistinct and testCountQueryDistinct).

The code for Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct:

  $query = db_select('test_task');
  $query->addField('test_task', 'task');
  $query->distinct();
  $query_result = $query->countQuery()->execute()->fetchField();

  $this->assertEqual($query_result, 6, 'Returned the correct number of rows.');

The code for Drupal\KernelTests\Core\Database\SelectComplexTest::testCountQueryDistinct:

  $query = db_select('test_task');
  $query->addField('test_task', 'task');
  $query->distinct();

  $count = $query->countQuery()->execute()->fetchField();

  $this->assertEqual($count, 6, 'Counted the correct number of records.');

Steps to reproduce

Proposed resolution

Lets change the code for Drupal\KernelTests\Core\Database\SelectComplexTest::testDistinct to:

  $query = db_select('test_task');
  $query->addField('test_task', 'task');
  $query->distinct();
  $query_result = $query->execute()->fetchAll(\PDO::FETCH_COLUMN);

  $this->assertEqual(count($query_result), 6, 'Returned the correct number of rows.');

  $correct_result = ['eat', 'sleep', 'code', 'sing', 'found new band', 'perform at superbowl'];
  $this->assertEqual($query_result, $correct_result, 'Returned the correct number of rows.');

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Fixed

Version

9.5

Component
DatabaseΒ  β†’

Last updated 2 days ago

  • Maintained by
  • πŸ‡³πŸ‡±Netherlands @daffie
Created by

πŸ‡³πŸ‡±Netherlands daffie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024