Skip to content

Commit

Permalink
Merge pull request #11807 from lyyana/patch-1
Browse files Browse the repository at this point in the history
"hold_date" not updated if civimail_multiple_bulk_emails is true + test
  • Loading branch information
eileenmcnaughton authored Mar 28, 2018
2 parents 83c9551 + 916f11f commit 778e350
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CRM/Core/BAO/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ public static function allEntityEmails(&$entityElements) {
* Email object.
*/
public static function holdEmail(&$email) {
if (!($email->on_hold === 'null' || $email->on_hold === NULL)) {
$email->on_hold = intval($email->on_hold);
}
//check for update mode
if ($email->id) {
$params = array(1 => array($email->id, 'Integer'));
Expand Down
34 changes: 34 additions & 0 deletions tests/phpunit/api/v3/EmailTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -376,4 +376,38 @@ public function testReplaceEmailWithId() {
$this->assertEquals('1-2@example.com', $get['values'][$emailID]['email']);
}

public function testEmailOnHold() {
$params = array();
$params_change = array();
$params = array(
'contact_id' => $this->_contactID,
'email' => 'api@a-team.com',
'on_hold' => '2',
);
$result = $this->callAPIAndDocument('email', 'create', $params, __FUNCTION__, __FILE__);
$this->assertEquals(1, $result['count']);
$this->assertNotNull($result['id']);
$this->assertNotNull($result['values'][$result['id']]['id']);
$this->assertEquals(2, $result['values'][$result['id']]['on_hold']);
$this->assertEquals(date('Y-m-d H:i'), date('Y-m-d H:i', strtotime($result['values'][$result['id']]['hold_date'])));

// set on_hold is '0'
// if isMultipleBulkMail is active, the value in On-hold select is string
$params_change = array(
'id' => $result['id'],
'contact_id' => $this->_contactID,
'email' => 'api@a-team.com',
'is_primary' => 1,
'on_hold' => '0',
);
$result_change = $this->callAPISuccess('email', 'create', $params_change + array('action' => 'get'));
$this->assertEquals(1, $result_change['count']);
$this->assertEquals($result['id'], $result_change['id']);
$this->assertEmpty($result_change['values'][$result_change['id']]['on_hold']);
$this->assertEquals(date('Y-m-d H:i'), date('Y-m-d H:i', strtotime($result_change['values'][$result_change['id']]['reset_date'])));
$this->assertEmpty($result_change['values'][$result_change['id']]['hold_date']);

$delresult = $this->callAPISuccess('email', 'delete', array('id' => $result['id']));
}

}

0 comments on commit 778e350

Please sign in to comment.