3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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 +--------------------------------------------------------------------+
29 * Test APIv3 civicrm_mailing_group_* functions
34 class api_v3_MailingGroupTest
extends CiviUnitTestCase
{
37 protected $_apiversion;
39 public function setUp() {
41 $this->useTransaction(TRUE);
42 $this->_apiversion
= 3;
43 $this->_groupID
= $this->groupCreate();
44 $this->_email
= 'test@test.test';
48 * Test civicrm_mailing_group_event_subscribe with wrong params.
50 public function testMailerGroupSubscribeWrongParams() {
52 'email' => $this->_email
,
53 'group_id' => 'Wrong Group ID',
54 'contact_id' => '2121',
55 'time_stamp' => '20111111010101',
58 $this->callAPIFailure('mailing_event_subscribe', 'create', $params);
62 * Test civicrm_mailing_group_event_subscribe with given contact ID.
64 public function testMailerGroupSubscribeGivenContactId() {
66 'first_name' => 'Test',
67 'last_name' => 'Test',
68 'email' => $this->_email
,
69 'contact_type' => 'Individual',
71 $contactID = $this->individualCreate($params);
74 'email' => $this->_email
,
75 'group_id' => $this->_groupID
,
76 'contact_id' => $contactID,
77 'hash' => 'b15de8b64e2cec34',
78 'time_stamp' => '20101212121212',
80 $result = $this->callAPIAndDocument('mailing_event_subscribe', 'create', $params, __FUNCTION__
, __FILE__
);
81 $this->assertEquals($result['values'][$result['id']]['contact_id'], $contactID);
83 $this->contactDelete($contactID);
87 * Test civicrm_mailing_group_event_unsubscribe with wrong params.
89 public function testMailerGroupUnsubscribeWrongParams() {
91 'job_id' => 'Wrong ID',
92 'event_queue_id' => 'Wrong ID',
93 'hash' => 'Wrong Hash',
94 'time_stamp' => '20101212121212',
97 $this->callAPIFailure('mailing_event_unsubscribe', 'create', $params);
101 * Test civicrm_mailing_group_event_domain_unsubscribe with wrong params.
103 public function testMailerGroupDomainUnsubscribeWrongParams() {
105 'job_id' => 'Wrong ID',
106 'event_queue_id' => 'Wrong ID',
107 'hash' => 'Wrong Hash',
108 'org_unsubscribe' => 1,
109 'time_stamp' => '20101212121212',
112 $this->callAPIFailure('mailing_event_unsubscribe', 'create', $params);
116 * Test civicrm_mailing_group_event_resubscribe with wrong params type.
120 * Test civicrm_mailing_group_event_resubscribe with wrong params.
122 public function testMailerGroupResubscribeWrongParams() {
124 'job_id' => 'Wrong ID',
125 'event_queue_id' => 'Wrong ID',
126 'hash' => 'Wrong Hash',
127 'org_unsubscribe' => 'test',
128 'time_stamp' => '20101212121212',
130 $this->callAPIFailure('mailing_event_resubscribe', 'create', $params);
134 * Test civicrm_mailing_group_event_subscribe and civicrm_mailing_event_confirm functions - success expected.
136 public function testMailerProcess() {
138 'first_name' => 'Test',
139 'last_name' => 'Test',
140 'email' => $this->_email
,
141 'contact_type' => 'Individual',
143 $contactID = $this->individualCreate($params);
146 'email' => $this->_email
,
147 'group_id' => $this->_groupID
,
148 'contact_id' => $contactID,
149 'hash' => 'b15de8b64e2cec34',
150 'time_stamp' => '20101212121212',
152 $result = $this->callAPISuccess('mailing_event_subscribe', 'create', $params);
154 $this->assertEquals($result['values'][$result['id']]['contact_id'], $contactID);
157 'contact_id' => $result['values'][$result['id']]['contact_id'],
158 'subscribe_id' => $result['values'][$result['id']]['subscribe_id'],
159 'hash' => $result['values'][$result['id']]['hash'],
160 'time_stamp' => '20101212121212',
161 'event_subscribe_id' => $result['values'][$result['id']]['subscribe_id'],
164 $this->callAPISuccess('mailing_event_confirm', 'create', $params);
165 $this->contactDelete($contactID);