From 3cf708ce227bf8f7c8ba8a58b6d1b58ac72cdd6b Mon Sep 17 00:00:00 2001 From: "deb.monish" Date: Wed, 14 Dec 2016 11:27:04 +0530 Subject: [PATCH] add sort order --- tests/phpunit/CRM/Contact/BAO/GroupContactTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php index c25ffa7ceb..9bc3f107dd 100644 --- a/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php +++ b/tests/phpunit/CRM/Contact/BAO/GroupContactTest.php @@ -171,18 +171,21 @@ class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase { // Create contact with Gender - Male $contact1 = $this->individualCreate(array( 'gender_id' => "Male", + 'first_name' => 'A', )); // Create contact with Gender - Male and in regular group $contact2 = $this->individualCreate(array( 'group' => array($regularGroup['id'] => 1), 'gender_id' => "Male", + 'first_name' => 'B', ), 1); // Create contact with Gender - Female and in regular group $contact3 = $this->individualCreate(array( 'group' => array($regularGroup['id'] => 1), 'gender_id' => "Female", + 'first_name' => 'C', ), 1); // create smart group based on saved criteria Gender = Male @@ -220,7 +223,7 @@ class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase { foreach ($useCases as $case) { $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($case['form_value'])); list($select, $from, $where, $having) = $query->query(); - $groupContacts = CRM_Core_DAO::executeQuery("SELECT DISTINCT contact_a.id $from $where")->fetchAll(); + $groupContacts = CRM_Core_DAO::executeQuery("SELECT DISTINCT contact_a.* $from $where ORDER BY contact_a.first_name")->fetchAll(); foreach ($groupContacts as $key => $value) { $groupContacts[$key] = $value['id']; } @@ -256,11 +259,13 @@ class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase { // create contact in 'Group 1' $contact1 = $this->individualCreate(array( 'group' => array($group1['id'] => 1), + 'first_name' => 'A', )); // create contact in 'Group 2' $contact2 = $this->individualCreate(array( 'group' => array($group2['id'] => 1), + 'first_name' => 'B', ), 1); $useCases = array( @@ -287,7 +292,7 @@ class CRM_Contact_BAO_GroupContactTest extends CiviUnitTestCase { foreach ($useCases as $case) { $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($case['form_value'])); list($select, $from, $where, $having) = $query->query(); - $groupContacts = CRM_Core_DAO::executeQuery("SELECT DISTINCT contact_a.id $from $where")->fetchAll(); + $groupContacts = CRM_Core_DAO::executeQuery("SELECT DISTINCT contact_a.id $from $where ORDER BY contact_a.first_name")->fetchAll(); foreach ($groupContacts as $key => $value) { $groupContacts[$key] = $value['id']; } -- 2.25.1