Skip to content

Commit

Permalink
test failure fix
Browse files Browse the repository at this point in the history
  • Loading branch information
monishdeb committed Dec 19, 2017
1 parent 6dd717a commit 6ec61f1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CRM/Mailing/BAO/Mailing.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public static function getRecipients($mailingID) {
$orderBy = array("MIN(i.contact_id)", "MIN(i.$tempColumn)");
$query = $query->join('e', " INNER JOIN civicrm_email e ON e.id = i.email_id ")->groupBy("e.email");
if (CRM_Utils_SQL::supportsFullGroupBy()) {
$selectClause[] = "e.email";
$selectClause = array('#mailingID', 'ANY_VALUE(i.contact_id) contact_id', "ANY_VALUE(i.$tempColumn) $tempColumn", "e.email");
}
}

Expand Down
15 changes: 10 additions & 5 deletions tests/phpunit/CiviTest/CiviUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1018,12 +1018,13 @@ public function organizationCreate($params = array(), $seq = 0) {
* parameters for civicrm_contact_add api function call
* @param int $seq
* sequence number if creating multiple individuals
* @param bool $random
*
* @return int
* id of Individual created
*/
public function individualCreate($params = array(), $seq = 0) {
$params = array_merge($this->sampleContact('Individual', $seq), $params);
public function individualCreate($params = array(), $seq = 0, $random = FALSE) {
$params = array_merge($this->sampleContact('Individual', $seq, $random), $params);
return $this->_contactCreate($params);
}

Expand Down Expand Up @@ -1054,7 +1055,7 @@ public function householdCreate($params = array(), $seq = 0) {
* @return array
* properties of sample contact (ie. $params for API call)
*/
public function sampleContact($contact_type, $seq = 0) {
public function sampleContact($contact_type, $seq = 0, $random = FALSE) {
$samples = array(
'Individual' => array(
// The number of values in each list need to be coprime numbers to not have duplicates
Expand All @@ -1078,6 +1079,9 @@ public function sampleContact($contact_type, $seq = 0) {
$params = array('contact_type' => $contact_type);
foreach ($samples[$contact_type] as $key => $values) {
$params[$key] = $values[$seq % count($values)];
if ($random) {
$params[$key] .= substr(sha1(rand()), 0, 5);
}
}
if ($contact_type == 'Individual') {
$params['email'] = strtolower(
Expand Down Expand Up @@ -1870,13 +1874,14 @@ public function smartGroupCreate($smartGroupParams = array(), $groupParams = arr
*
* @param int $groupID
* @param int $totalCount
* @param bool $random
* @return int
* groupId of created group
*/
public function groupContactCreate($groupID, $totalCount = 10) {
public function groupContactCreate($groupID, $totalCount = 10, $random = FALSE) {
$params = array('group_id' => $groupID);
for ($i = 1; $i <= $totalCount; $i++) {
$contactID = $this->individualCreate();
$contactID = $this->individualCreate(array(), 0, $random);
if ($i == 1) {
$params += array('contact_id' => $contactID);
}
Expand Down
3 changes: 1 addition & 2 deletions tests/phpunit/api/v3/MailingABTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ public function groupPctProvider() {
* @dataProvider groupPctProvider
*/
public function testDistribution($totalGroupContacts, $groupPct, $expectedCountA, $expectedCountB, $expectedCountC) {

$result = $this->groupContactCreate($this->_groupID, $totalGroupContacts);
$result = $this->groupContactCreate($this->_groupID, $totalGroupContacts, TRUE);
$this->assertEquals($totalGroupContacts, $result['added'], "in line " . __LINE__);

$params = $this->_params;
Expand Down

0 comments on commit 6ec61f1

Please sign in to comment.