3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 | |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
28 * Test class for CRM_Contact_Form_Task_EmailCommon.
31 class CRM_Contact_Form_Task_EmailCommonTest
extends CiviUnitTestCase
{
33 protected function setUp() {
35 $this->_contactIds
= array(
36 $this->individualCreate(array('first_name' => 'Antonia', 'last_name' => 'D`souza')),
37 $this->individualCreate(array('first_name' => 'Anthony', 'last_name' => 'Collins')),
39 $this->_optionValue
= $this->callApiSuccess('optionValue', 'create', array(
40 'label' => '"Seamus Lee" <seamus@example.com>',
41 'option_group_id' => 'from_email_address',
46 * Test generating domain emails
48 public function testDomainEmailGeneration() {
49 $emails = CRM_Core_BAO_Email
::domainEmails();
50 $this->assertNotEmpty($emails);
51 $optionValue = $this->callAPISuccess('OptionValue', 'Get', array(
52 'id' => $this->_optionValue
['id'],
54 $this->assertTrue(array_key_exists('"Seamus Lee" <seamus@example.com>', $emails));
55 $this->assertEquals('"Seamus Lee" <seamus@example.com>', $optionValue['values'][$this->_optionValue
['id']]['label']);
58 public function testPostProcess() {
59 $this->createLoggedInUser();
60 $form = new CRM_Contact_Form_Task_Email();
61 $_SERVER['REQUEST_METHOD'] = 'GET';
62 $form->controller
= new CRM_Core_Controller();
64 for ($i = 0; $i < 27; $i++
) {
65 $email = 'spy' . $i . '@secretsquirrels.com';
66 $contactID = $this->individualCreate(array('email' => $email));
67 $form->_contactIds
[$contactID] = $contactID;
68 $form->_toContactEmails
[$this->callAPISuccessGetValue('Email', array('return' => 'id', 'email' => $email))] = $email;
70 $form->_allContactIds
= $form->_toContactIds
= $form->_contactIds
;
71 $form->_emails
= array(1 => 'mickey@mouse.com');
72 $form->_fromEmails
= array(1 => 'mickey@mouse.com');
74 CRM_Contact_Form_Task_EmailCommon
::buildQuickForm($form);
76 CRM_Contact_Form_Task_EmailCommon
::submit($form, array(
77 'fromEmailAddress' => 1,
78 'subject' => 'Really interesting stuff',