From 480a9346b927c4bf8a7b85d9f31a043c055236ac Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 3 Jul 2018 14:21:30 +1200 Subject: [PATCH] Fix fatal error on send test mail --- api/v3/Mailing.php | 9 +++++++-- tests/phpunit/api/v3/MailingTest.php | 6 ++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/api/v3/Mailing.php b/api/v3/Mailing.php index 7a7257693c..39df78ef10 100644 --- a/api/v3/Mailing.php +++ b/api/v3/Mailing.php @@ -598,6 +598,8 @@ function civicrm_api3_mailing_preview($params) { function _civicrm_api3_mailing_send_test_spec(&$spec) { $spec['test_group']['title'] = 'Test Group ID'; $spec['test_email']['title'] = 'Test Email Address'; + $spec['mailing_id']['api.required'] = TRUE; + $spec['mailing_id']['title'] = ts('Mailing Id'); } /** @@ -620,6 +622,10 @@ function civicrm_api3_mailing_send_test($params) { ); $testEmailParams = _civicrm_api3_generic_replace_base_params($params); + if (isset($testEmailParams['id'])) { + unset($testEmailParams['id']); + } + $testEmailParams['is_test'] = 1; $testEmailParams['status'] = 'Scheduled'; $testEmailParams['scheduled_date'] = CRM_Utils_Date::processDate(date('Y-m-d'), date('H:i:s')); @@ -679,8 +685,7 @@ function civicrm_api3_mailing_send_test($params) { } $isComplete = FALSE; - $config = CRM_Core_Config::singleton(); - $mailerJobSize = Civi::settings()->get('mailerJobSize'); + while (!$isComplete) { // Q: In CRM_Mailing_BAO_Mailing::processQueue(), the three runJobs*() // functions are all called. Why does Mailing.send_test only call one? diff --git a/tests/phpunit/api/v3/MailingTest.php b/tests/phpunit/api/v3/MailingTest.php index 695203bbc6..e480e78042 100644 --- a/tests/phpunit/api/v3/MailingTest.php +++ b/tests/phpunit/api/v3/MailingTest.php @@ -398,7 +398,7 @@ class api_v3_MailingTest extends CiviUnitTestCase { } /** - * + * Test sending a test mailing. */ public function testMailerSendTest_email() { $contactIDs['alice'] = $this->individualCreate(array( @@ -410,8 +410,10 @@ class api_v3_MailingTest extends CiviUnitTestCase { $mail = $this->callAPISuccess('mailing', 'create', $this->_params); $params = array('mailing_id' => $mail['id'], 'test_email' => 'alice@example.org', 'test_group' => NULL); + // Per https://lab.civicrm.org/dev/core/issues/229 ensure this is not passed through! + $params['id'] = $mail['id']; $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params); - $this->assertEquals(1, $deliveredInfo['count'], "in line " . __LINE__); // verify mail has been sent to user by count + $this->assertEquals(1, $deliveredInfo['count']); // verify mail has been sent to user by count $deliveredContacts = array_values(CRM_Utils_Array::collect('contact_id', $deliveredInfo['values'])); $this->assertEquals(array($contactIDs['alice']), $deliveredContacts); -- 2.25.1