Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
MarketingListsExternalControllerWalkthroughTest.php
1 <?php
2  /*********************************************************************************
3  * Zurmo is a customer relationship management program developed by
4  * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc.
5  *
6  * Zurmo is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  *
13  * Zurmo is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  *
23  * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive
24  * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com.
25  *
26  * The interactive user interfaces in original and modified versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  *
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the Zurmo
32  * logo and Zurmo copyright notice. If the display of the logo is not reasonably
33  * feasible for technical reasons, the Appropriate Legal Notices must display the words
34  * "Copyright Zurmo Inc. 2017. All rights reserved".
35  ********************************************************************************/
36 
38  {
39  protected $subscribeUrl = '/marketingLists/external/subscribe';
40 
41  protected $unsubscribeUrl = '/marketingLists/external/unsubscribe';
42 
43  protected $optOutUrl = '/marketingLists/external/optOut';
44 
45  protected $manageSubscriptionsUrl = '/marketingLists/external/manageSubscriptions';
46 
47  public static function setUpBeforeClass()
48  {
49  parent::setUpBeforeClass();
50  SecurityTestHelper::createSuperAdmin();
52  }
53 
59  {
60  $this->runControllerWithNoExceptionsAndGetContent($this->subscribeUrl);
61  }
62 
69  {
70  $this->runControllerWithNoExceptionsAndGetContent($this->unsubscribeUrl);
71  }
72 
79  {
80  $this->runControllerWithNoExceptionsAndGetContent($this->optOutUrl);
81  }
82 
89  {
90  $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
91  }
92 
98  {
99  $hash = 'Bo9iemeigh6muath8chu2leThohn8Abimoh5rebaihei4aiM1uFoThaith9eng1sei8aisuHu1ugoophiewoe1ieloo';
100  $this->setGetArray(array(
101  'hash' => $hash,
102  ));
103  $this->runControllerWithNoExceptionsAndGetContent($this->subscribeUrl);
104  }
105 
111  {
112  $hash = 'Bo9iemeigh6muath8chu2leThohn8Abimoh5rebaihei4aiM1uFoThaith9eng1sei8aisuHu1ugoophiewoe1ieloo';
113  $this->setGetArray(array(
114  'hash' => $hash,
115  ));
116  $this->runControllerWithNoExceptionsAndGetContent($this->unsubscribeUrl);
117  }
118 
124  {
125  $hash = 'Bo9iemeigh6muath8chu2leThohn8Abimoh5rebaihei4aiM1uFoThaith9eng1sei8aisuHu1ugoophiewoe1ieloo';
126  $this->setGetArray(array(
127  'hash' => $hash,
128  ));
129  $this->runControllerWithNoExceptionsAndGetContent($this->optOutUrl);
130  }
131 
137  {
138  $hash = 'Bo9iemeigh6muath8chu2leThohn8Abimoh5rebaihei4aiM1uFoThaith9eng1sei8aisuHu1ugoophiewoe1ieloo';
139  $this->setGetArray(array(
140  'hash' => $hash,
141  ));
142  $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
143  }
144 
150  {
151  $hash = 'DEDF8F6C80D20528130EBBFBD293E49C9E2F0CBFDE8995FFE4EEAD8EC8F00B70';
152  $this->setGetArray(array(
153  'hash' => $hash,
154  ));
155  $this->runControllerWithNoExceptionsAndGetContent($this->subscribeUrl);
156  }
157 
163  {
164  $hash = 'DEDF8F6C80D20528130EBBFBD293E49C9E2F0CBFDE8995FFE4EEAD8EC8F00B70';
165  $this->setGetArray(array(
166  'hash' => $hash,
167  ));
168  $this->runControllerWithNoExceptionsAndGetContent($this->unsubscribeUrl);
169  }
170 
176  {
177  $hash = 'DEDF8F6C80D20528130EBBFBD293E49C9E2F0CBFDE8995FFE4EEAD8EC8F00B70';
178  $this->setGetArray(array(
179  'hash' => $hash,
180  ));
181  $this->runControllerWithNoExceptionsAndGetContent($this->optOutUrl);
182  }
183 
189  {
190  $hash = 'DEDF8F6C80D20528130EBBFBD293E49C9E2F0CBFDE8995FFE4EEAD8EC8F00B70';
191  $this->setGetArray(array(
192  'hash' => $hash,
193  ));
194  $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
195  }
196 
202  {
203  $queryStringArray = array(
204  'keyOne' => 'valueOne',
205  'keyTwo' => 'valueTwo',
206  'keyThree' => 'ValueThree',
207  );
208  $hash = StringUtil::resolveHashForQueryStringArray($queryStringArray);
209  $this->setGetArray(array(
210  'hash' => $hash,
211  ));
212  $this->runControllerWithNoExceptionsAndGetContent($this->subscribeUrl);
213  }
214 
220  {
221  $queryStringArray = array(
222  'keyOne' => 'valueOne',
223  'keyTwo' => 'valueTwo',
224  'keyThree' => 'ValueThree',
225  );
226  $hash = StringUtil::resolveHashForQueryStringArray($queryStringArray);
227  $this->setGetArray(array(
228  'hash' => $hash,
229  ));
230  $this->runControllerWithNoExceptionsAndGetContent($this->unsubscribeUrl);
231  }
232 
238  {
239  $queryStringArray = array(
240  'keyOne' => 'valueOne',
241  'keyTwo' => 'valueTwo',
242  'keyThree' => 'ValueThree',
243  );
244  $hash = StringUtil::resolveHashForQueryStringArray($queryStringArray);
245  $this->setGetArray(array(
246  'hash' => $hash,
247  ));
248  $this->runControllerWithNoExceptionsAndGetContent($this->optOutUrl);
249  }
250 
256  {
257  $queryStringArray = array(
258  'keyOne' => 'valueOne',
259  'keyTwo' => 'valueTwo',
260  'keyThree' => 'ValueThree',
261  );
262  $hash = StringUtil::resolveHashForQueryStringArray($queryStringArray);
263  $this->setGetArray(array(
264  'hash' => $hash,
265  ));
266  $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
267  }
268 
274  {
276  $contact = ContactTestHelper::createContactByNameForOwner('contact 01', Yii::app()->user->userModel);
277  Yii::app()->user->userModel = null;
278  $personId = $contact->getClassId('Person');
279  $hash = GlobalMarketingFooterUtil::resolveHash($personId, 100, 1, 'AutoresponderItem', false);
280  $this->setGetArray(array(
281  'hash' => $hash,
282  ));
283  $this->runControllerWithNoExceptionsAndGetContent($this->subscribeUrl);
284  }
285 
291  {
293  $contact = ContactTestHelper::createContactByNameForOwner('contact 02', Yii::app()->user->userModel);
294  Yii::app()->user->userModel = null;
295  $personId = $contact->getClassId('Person');
296  $hash = GlobalMarketingFooterUtil::resolveHash($personId, 100, 1, 'AutoresponderItem', false);
297  $this->setGetArray(array(
298  'hash' => $hash,
299  ));
300  $this->runControllerWithNoExceptionsAndGetContent($this->unsubscribeUrl);
301  }
302 
308  {
310  $contact = ContactTestHelper::createContactByNameForOwner('contact 03', Yii::app()->user->userModel);
311  Yii::app()->user->userModel = null;
312  $personId = $contact->getClassId('Person');
313  $hash = GlobalMarketingFooterUtil::resolveHash($personId, 100, 1, 'AutoresponderItem', false);
314  $this->setGetArray(array(
315  'hash' => $hash,
316  ));
317  $this->runControllerWithNoExceptionsAndGetContent($this->optOutUrl);
318  }
319 
324  {
326  $contact = ContactTestHelper::createContactByNameForOwner('contact 04', Yii::app()->user->userModel);
327  Yii::app()->user->userModel = null;
328  $personId = $contact->getClassId('Person');
329  $hash = GlobalMarketingFooterUtil::resolveHash($personId, 100, 1, 'AutoresponderItem', false);
330  $this->setGetArray(array(
331  'hash' => $hash,
332  ));
333  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
334  $this->assertContains('<title>ZurmoCRM - Manage Subscriptions</title>', $content);
335  $this->assertContains('<div class="GridView">', $content);
336  $this->assertNotContains('<div id="HeaderLinksView">', $content);
337  $this->assertContains('<div id="MarketingListsManageSubscriptionsListView" ' .
338  'class="MetadataView">', $content);
339  $this->assertContains('<div class="wrapper">', $content);
340  $this->assertContains('<h1><span class="truncated-title"><span class="ellipsis-content">' .
341  'My Subscriptions</span></span></h1>', $content);
342  $this->assertContains('<div class="wide" ' .
343  'id="marketingLists-manageSubscriptionsList">', $content);
344  $this->assertContains('<colgroup><col style="width:20%" />' .
345  '<col style="width:80%" /></colgroup>', $content);
346  $this->assertContains('<td><a class="simple-link marketingListsManage' .
347  'SubscriptionListView-toggleUnsubscribed"', $content);
348  $this->assertContains('/marketingLists/external/optOut?hash=', $content);
349  $this->assertContains('>Unsubscribe All/OptOut</a>', $content);
350  $this->assertContains('<footer id="FooterView">', $content);
351  $this->assertContains('<a href="http://www.zurmo.com" id="credit-link" ' .
352  'class="clearfix">', $content);
353  $this->assertContains('<span>Copyright &#169; Zurmo Inc., 2019. ' .
354  'All rights reserved.</span></a>', $content);
355  }
356 
362  {
364  $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 01',
365  'description',
366  'fromName',
367  'from@domain.com',
368  true);
369  Yii::app()->user->userModel = null;
370  $hash = GlobalMarketingFooterUtil::resolveHash(100, $marketingList->id, 1,
371  'AutoresponderItem', false);
372  $this->setGetArray(array(
373  'hash' => $hash,
374  ));
375  $this->runControllerWithNoExceptionsAndGetContent($this->subscribeUrl);
376  }
377 
383  {
385  $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 02',
386  'description',
387  'fromName',
388  'from@domain.com',
389  false);
390  Yii::app()->user->userModel = null;
391  $hash = GlobalMarketingFooterUtil::resolveHash(100, $marketingList->id, 1,
392  'AutoresponderItem', false);
393  $this->setGetArray(array(
394  'hash' => $hash,
395  ));
396  $this->runControllerWithNoExceptionsAndGetContent($this->unsubscribeUrl);
397  }
398 
404  {
406  $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 03',
407  'description',
408  'fromName',
409  'from@domain.com',
410  true);
411  Yii::app()->user->userModel = null;
412  $hash = GlobalMarketingFooterUtil::resolveHash(100, $marketingList->id, 1,
413  'AutoresponderItem', false);
414  $this->setGetArray(array(
415  'hash' => $hash,
416  ));
417  $this->runControllerWithNoExceptionsAndGetContent($this->optOutUrl);
418  }
419 
425  {
427  $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 04',
428  'description',
429  'fromName',
430  'from@domain.com',
431  false);
432  Yii::app()->user->userModel = null;
433  $hash = GlobalMarketingFooterUtil::resolveHash(100, $marketingList->id, 1,
434  'AutoresponderItem', false);
435  $this->setGetArray(array(
436  'hash' => $hash,
437  ));
438  $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
439  }
440 
445  {
447  $contact = ContactTestHelper::createContactByNameForOwner('contact 05', Yii::app()->user->userModel);
448  $personId = $contact->getClassId('Person');
449  $subscribedIds = array();
450  for ($index = 1; $index < 5; $index++)
451  {
452  $marketingListName = 'marketingList 0' . $index;
453  $marketingList = MarketingList::getByName($marketingListName);
454  $marketingList = $marketingList[0];
455  $unsubscribed = ($index % 2);
456  if (!$unsubscribed)
457  {
458  $subscribedIds[] = $marketingList->id;
459  }
460  MarketingListMemberTestHelper::createMarketingListMember($unsubscribed, $marketingList, $contact);
461  }
462  Yii::app()->user->userModel = null;
463  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingList->id, 1,
464  'AutoresponderItem', false);
465  $this->setGetArray(array(
466  'hash' => $hash,
467  ));
468  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
469  $this->assertContains('<title>ZurmoCRM - Manage Subscriptions</title>', $content);
470  $this->assertContains('<div class="GridView">', $content);
471  $this->assertNotContains('<div id="HeaderLinksView">', $content);
472  $this->assertContains('<div id="MarketingListsManageSubscriptionsListView" ' .
473  'class="MetadataView">', $content);
474  $this->assertContains('<div class="wrapper">', $content);
475  $this->assertContains('<h1><span class="truncated-title"><span class="ellipsis-content">' .
476  'My Subscriptions</span></span></h1>', $content);
477  $this->assertContains('<div class="wide" ' .
478  'id="marketingLists-manageSubscriptionsList">', $content);
479  $this->assertContains('<colgroup><col style="width:20%" />' .
480  '<col style="width:80%" /></colgroup>', $content);
481  $this->assertContains('<td><a class="simple-link marketingListsManage' .
482  'SubscriptionListView-toggleUnsubscribed"', $content);
483  $this->assertContains('/marketingLists/external/optOut?hash=', $content);
484  $this->assertContains('>Unsubscribe All/OptOut</a></td>', $content);
485  $this->assertContains('<footer id="FooterView">', $content);
486  $this->assertContains('<a href="http://www.zurmo.com" id="credit-link" ' .
487  'class="clearfix">', $content);
488  $this->assertContains('<span>Copyright &#169; Zurmo Inc., 2019. ' .
489  'All rights reserved.</span></a>', $content);
490  $this->assertContains('<td>marketingList 02</td>', $content);
491  $this->assertContains('<td><div class="switch">', $content);
492  $this->assertContains('<div class="switch-state clearfix">', $content);
493  $this->assertContains('/marketingLists/external/subscribe?hash=', $content);
494  $this->assertContains('id="marketingListsManage' .
495  'SubscriptionListView-toggleUnsubscribed_', $content);
496  $this->assertContains('checked="checked" type="radio" name="marketingListsManage' .
497  'SubscriptionListView-toggleUnsubscribed_', $content);
498  $this->assertContains('<label for="marketingListsManage' .
499  'SubscriptionListView-toggleUnsubscribed_', $content);
500  $this->assertContains('_0">Subscribe</label></div>', $content);
501  $this->assertContains('/marketingLists/external/unsubscribe?hash=', $content);
502  $this->assertContains('_1">Unsubcribe</label></div></div></td>', $content);
503  $this->assertContains('<td>marketingList 01</td>', $content);
504  $this->assertContains('<td>marketingList 03</td>', $content);
505  $this->assertContains('<td>marketingList 04</td>', $content);
506  $this->assertEquals(4, substr_count($content, '_0">Subscribe</label></div>'));
507  $this->assertEquals(4, substr_count($content, '_1">Unsubcribe</label></div></div></td>'));
508  foreach ($subscribedIds as $subscribedId)
509  {
510  $this->assertContains('checked="checked" type="radio" name="marketingListsManage' .
511  'SubscriptionListView-toggleUnsubscribed_' . $subscribedId, $content);
512  }
513  }
514 
519  {
521  $marketingList = MarketingList::getByName('marketingList 04');
522  $this->assertNotEmpty($marketingList);
523  $marketingList = $marketingList[0];
524  $contact = Contact::getByName('contact 05 contact 05son');
525  $this->assertNotEmpty($contact);
526  $contact = $contact[0];
527  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
528  $contact->id,
529  0);
530  $this->assertNotEmpty($member);
531  $member[0]->delete();
532  $personId = $contact->getClassId('Person');
533  Yii::app()->user->userModel = null;
534  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingList->id, 1,
535  'AutoresponderItem', false);
536  $this->setGetArray(array(
537  'hash' => $hash,
538  ));
539  $this->runControllerWithRedirectExceptionAndGetUrl($this->subscribeUrl);
540  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
541  $this->assertNotEmpty($content);
542  $this->assertNotContains('<td>marketingList 04</td>', $content);
543  }
544 
549  {
551  $marketingList = MarketingList::getByName('marketingList 03');
552  $this->assertNotEmpty($marketingList);
553  $marketingList = $marketingList[0];
554  $marketingListId = $marketingList->id;
555  $contact = Contact::getByName('contact 05 contact 05son');
556  $this->assertNotEmpty($contact);
557  $contact = $contact[0];
558  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
559  $contact->id,
560  1);
561  $this->assertNotEmpty($member);
562  $member[0]->delete();
563  $personId = $contact->getClassId('Person');
564  Yii::app()->user->userModel = null;
565  // we set modelId to 0 and createNewActivity to true, so if it tries to create activity it will throw NotFoundException
566  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 0,
567  'AutoresponderItem', true);
568  $this->setGetArray(array(
569  'hash' => $hash,
570  ));
571  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
572  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
573  $marketingListId . '_0" type="radio" name="marketingListsManage' .
574  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
575  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
576  $marketingListId . '_1" checked="checked" type="radio" name="marketingListsManage' .
577  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
578  @$this->runControllerWithRedirectExceptionAndGetUrl($this->subscribeUrl);
579  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
580  $this->assertNotEmpty($content);
581  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
582  $marketingListId . '_0" checked="checked" type="radio" name="marketingListsManage' .
583  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
584  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
585  $marketingListId . '_1" type="radio" name="marketingListsManage' .
586  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
587  }
588 
593  {
595  $marketingList = MarketingList::getByName('marketingList 03');
596  $this->assertNotEmpty($marketingList);
597  $marketingList = $marketingList[0];
598  $marketingListId = $marketingList->id;
599  $contact = Contact::getByName('contact 05 contact 05son');
600  $this->assertNotEmpty($contact);
601  $contact = $contact[0];
602  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
603  $contact->id,
604  0);
605  $this->assertNotEmpty($member);
606  $this->assertEquals(0, $member[0]->unsubscribed);
607  $personId = $contact->getClassId('Person');
608  Yii::app()->user->userModel = null;
609  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 1,
610  'AutoresponderItem', false);
611  $this->setGetArray(array(
612  'hash' => $hash,
613  ));
614  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
615  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
616  $marketingListId . '_0" checked="checked" type="radio" name="marketingListsManage' .
617  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
618  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
619  $marketingListId . '_1" type="radio" name="marketingListsManage' .
620  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
621  $this->runControllerWithRedirectExceptionAndGetUrl($this->subscribeUrl);
622  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
623  $this->assertNotEmpty($content);
624  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
625  $marketingListId . '_0" checked="checked" type="radio" name="marketingListsManage' .
626  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
627  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
628  $marketingListId . '_1" type="radio" name="marketingListsManage' .
629  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
630  }
631 
636  {
638  $marketingList = MarketingList::getByName('marketingList 03');
639  $this->assertNotEmpty($marketingList);
640  $marketingList = $marketingList[0];
641  $marketingListId = $marketingList->id;
642  $contact = Contact::getByName('contact 05 contact 05son');
643  $this->assertNotEmpty($contact);
644  $contact = $contact[0];
645  $personId = $contact->getClassId('Person');
646  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
647  $contact->id,
648  0);
649  $this->assertNotEmpty($member);
650  $this->assertEquals(0, $member[0]->unsubscribed);
651  $autoresponder = AutoresponderTestHelper::createAutoresponder('Autoresponder 01',
652  'textContent',
653  'htmlContent',
654  10,
655  Autoresponder::OPERATION_UNSUBSCRIBE,
656  true,
657  $marketingList);
658  $this->assertNotEmpty($autoresponder);
659  $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(strtotime('-1 week'));
660  $autoresponderItem = AutoresponderItemTestHelper::createAutoresponderItem(1, $processDateTime,
661  $autoresponder, $contact);
662  $this->assertNotEmpty($autoresponderItem);
663  $autoresponderItemActivities = AutoresponderItemActivity::getByTypeAndModelIdAndPersonIdAndUrl(
664  AutoresponderItemActivity::TYPE_UNSUBSCRIBE,
665  $autoresponderItem->id,
666  $personId);
667  $this->assertEmpty($autoresponderItemActivities);
668  Yii::app()->user->userModel = null;
669  $hash = GlobalMarketingFooterUtil::resolveHash($personId,
670  $marketingListId,
671  $autoresponderItem->id,
672  'AutoresponderItem',
673  true);
674  $this->setGetArray(array(
675  'hash' => $hash,
676  ));
677  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
678  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
679  $marketingListId . '_0" checked="checked" type="radio" name="marketingListsManage' .
680  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
681  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
682  $marketingListId . '_1" type="radio" name="marketingListsManage' .
683  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
684  @$this->runControllerWithRedirectExceptionAndGetUrl($this->unsubscribeUrl);
685  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
686  $this->assertNotEmpty($content);
687  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
688  $marketingListId . '_0" type="radio" name="marketingListsManage' .
689  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
690  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
691  $marketingListId . '_1" checked="checked" type="radio" name="marketingListsManage' .
692  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
694  $autoresponderItemActivities = AutoresponderItemActivity::getByTypeAndModelIdAndPersonIdAndUrl(
695  AutoresponderItemActivity::TYPE_UNSUBSCRIBE,
696  $autoresponderItem->id,
697  $personId);
698  $this->assertNotEmpty($autoresponderItemActivities);
699  $this->assertCount(1, $autoresponderItemActivities);
700  }
701 
706  {
708  $marketingList = MarketingList::getByName('marketingList 04');
709  $this->assertNotEmpty($marketingList);
710  $marketingList = $marketingList[0];
711  $marketingListId = $marketingList->id;
712  $contact = Contact::getByName('contact 05 contact 05son');
713  $this->assertNotEmpty($contact);
714  $contact = $contact[0];
715  $marketingList->addNewMember($contact->id, false, $contact);
716  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
717  $contact->id,
718  0);
719  $this->assertNotEmpty($member);
720  $this->assertEquals(0, $member[0]->unsubscribed);
721  $personId = $contact->getClassId('Person');
722  $autoresponder = AutoresponderTestHelper::createAutoresponder('Autoresponder 02',
723  'textContent',
724  'htmlContent',
725  10,
726  Autoresponder::OPERATION_UNSUBSCRIBE,
727  true,
728  $marketingList);
729  $this->assertNotEmpty($autoresponder);
730  $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(strtotime('-1 week'));
731  $autoresponderItem = AutoresponderItemTestHelper::createAutoresponderItem(1, $processDateTime,
732  $autoresponder, $contact);
733  $this->assertNotEmpty($autoresponderItem);
734  $autoresponderItemActivities = AutoresponderItemActivity::getByTypeAndModelIdAndPersonIdAndUrl(
735  AutoresponderItemActivity::TYPE_UNSUBSCRIBE,
736  $autoresponderItem->id,
737  $personId);
738  $this->assertEmpty($autoresponderItemActivities);
739  Yii::app()->user->userModel = null;
740  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 1,
741  'AutoresponderItem', false);
742  $this->setGetArray(array(
743  'hash' => $hash,
744  ));
745  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
746  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
747  $marketingListId . '_0" checked="checked" type="radio" name="marketingListsManage' .
748  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
749  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
750  $marketingListId . '_1" type="radio" name="marketingListsManage' .
751  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
752  @$this->runControllerWithRedirectExceptionAndGetUrl($this->unsubscribeUrl);
753  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
754  $this->assertNotEmpty($content);
755  $this->assertNotContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
756  $marketingListId . '_0" type="radio" name="marketingListsManage' .
757  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
758  $this->assertNotContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
759  $marketingListId . '_1" checked="checked" type="radio" name="marketingListsManage' .
760  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
761  $this->assertNotContains('<td>marketingList 04</td>', $content);
763  $autoresponderItemActivities = AutoresponderItemActivity::getByTypeAndModelIdAndPersonIdAndUrl(
764  AutoresponderItemActivity::TYPE_UNSUBSCRIBE,
765  $autoresponderItem->id,
766  $personId);
767  $this->assertEmpty($autoresponderItemActivities);
768  }
769 
774  {
776  $marketingList = MarketingList::getByName('marketingList 03');
777  $this->assertNotEmpty($marketingList);
778  $marketingList = $marketingList[0];
779  $marketingListId = $marketingList->id;
780  $contact = Contact::getByName('contact 05 contact 05son');
781  $this->assertNotEmpty($contact);
782  $contact = $contact[0];
783  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
784  $contact->id,
785  1);
786  $this->assertNotEmpty($member);
787  $this->assertEquals(1, $member[0]->unsubscribed);
788  $personId = $contact->getClassId('Person');
789  Yii::app()->user->userModel = null;
790  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 1,
791  'AutoresponderItem', false);
792  $this->setGetArray(array(
793  'hash' => $hash,
794  ));
795  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
796  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
797  $marketingListId . '_0" type="radio" name="marketingListsManage' .
798  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
799  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
800  $marketingListId . '_1" checked="checked" type="radio" name="marketingListsManage' .
801  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
802  $this->runControllerWithRedirectExceptionAndGetUrl($this->unsubscribeUrl);
803  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
804  $this->assertNotEmpty($content);
805  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
806  $marketingListId . '_0" type="radio" name="marketingListsManage' .
807  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
808  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
809  $marketingListId . '_1" checked="checked" type="radio" name="marketingListsManage' .
810  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
811  }
812 
817  {
819  $marketingList = MarketingList::getByName('marketingList 04');
820  $this->assertNotEmpty($marketingList);
821  $marketingList = $marketingList[0];
822  $marketingListId = $marketingList->id;
823  $contact = Contact::getByName('contact 05 contact 05son');
824  $this->assertNotEmpty($contact);
825  $contact = $contact[0];
826  $marketingList->addNewMember($contact->id, true, $contact);
827  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
828  $contact->id,
829  1);
830  $this->assertNotEmpty($member);
831  $this->assertEquals(1, $member[0]->unsubscribed);
832  $personId = $contact->getClassId('Person');
833  Yii::app()->user->userModel = null;
834  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 1,
835  'AutoresponderItem', false);
836  $this->setGetArray(array(
837  'hash' => $hash,
838  ));
839  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
840  $this->assertNotContains('<td>marketingList 04</td>', $content);
841  $this->runControllerWithRedirectExceptionAndGetUrl($this->unsubscribeUrl);
842  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
843  $this->assertNotEmpty($content);
844  $this->assertNotContains('<td>marketingList 04</td>', $content);
845  }
846 
851  {
853  $marketingList = MarketingList::getByName('marketingList 03');
854  $this->assertNotEmpty($marketingList);
855  $marketingList = $marketingList[0];
856  $marketingListId = $marketingList->id;
857  $contact = Contact::getByName('contact 05 contact 05son');
858  $this->assertNotEmpty($contact);
859  $contact = $contact[0];
860  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
861  $contact->id,
862  1);
863  $this->assertNotEmpty($member);
864  $member[0]->delete();
865  $personId = $contact->getClassId('Person');
866  Yii::app()->user->userModel = null;
867  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 1,
868  'AutoresponderItem', false);
869  $this->setGetArray(array(
870  'hash' => $hash,
871  ));
872  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
873  $this->assertContains('<td>marketingList 03</td>', $content);
874  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
875  $marketingListId . '_0" type="radio" name="marketingListsManage' .
876  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
877  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
878  $marketingListId . '_1" checked="checked" type="radio" name="marketingListsManage' .
879  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
880  $this->runControllerWithRedirectExceptionAndGetUrl($this->unsubscribeUrl);
881  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
882  $this->assertNotEmpty($content);
883  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
884  $marketingListId . '_0" type="radio" name="marketingListsManage' .
885  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
886  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
887  $marketingListId . '_1" checked="checked" type="radio" name="marketingListsManage' .
888  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
889  $this->assertContains('<td>marketingList 03</td>', $content);
890  }
891 
896  {
898  $marketingList = MarketingList::getByName('marketingList 04');
899  $this->assertNotEmpty($marketingList);
900  $marketingList = $marketingList[0];
901  $marketingListId = $marketingList->id;
902  $contact = Contact::getByName('contact 05 contact 05son');
903  $this->assertNotEmpty($contact);
904  $contact = $contact[0];
905  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
906  $contact->id,
907  1);
908  $this->assertNotEmpty($member);
909  $member[0]->delete();
910  $personId = $contact->getClassId('Person');
911  Yii::app()->user->userModel = null;
912  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 1,
913  'AutoresponderItem', false);
914  $this->setGetArray(array(
915  'hash' => $hash,
916  ));
917  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
918  $this->assertNotContains('<td>marketingList 04</td>', $content);
919  $this->runControllerWithRedirectExceptionAndGetUrl($this->unsubscribeUrl);
920  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
921  $this->assertNotEmpty($content);
922  $this->assertNotContains('<td>marketingList 04</td>', $content);
923  }
924 
928  public function testOptOutAction()
929  {
931  $contact = Contact::getByName('contact 05 contact 05son');
932  $this->assertNotEmpty($contact);
933  $contact = $contact[0];
934  $this->assertEquals(0, $contact->primaryEmail->optOut);
935  $personId = $contact->getClassId('Person');
936  $marketingListIds = array();
937  for ($index = 1; $index < 5; $index++)
938  {
939  $marketingListName = 'marketingList 0' . $index;
940  $marketingList = MarketingList::getByName($marketingListName);
941  $this->assertNotEmpty($marketingList);
942  $marketingListIds[] = $marketingList[0]->id;
943  if ($index === 4)
944  {
945  $marketingList[0]->addNewMember($contact->id, false, $contact);
946  }
947  }
948  Yii::app()->user->userModel = null;
949  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListIds[0],
950  1, 'AutoresponderItem', false);
951  $this->setGetArray(array(
952  'hash' => $hash,
953  ));
954  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
955  $this->assertContains('<td>marketingList 01</td>', $content);
956  $this->assertContains('<td>marketingList 02</td>', $content);
957  $this->assertContains('<td>marketingList 03</td>', $content);
958  $this->assertContains('<td>marketingList 04</td>', $content);
959  $this->assertContains('marketingLists/external/subscribe?hash=', $content);
960  $this->assertContains('id="marketingListsManage' .
961  'SubscriptionListView-toggleUnsubscribed_', $content);
962  $this->assertContains('id="marketingListsManage' .
963  'SubscriptionListView-toggleUnsubscribed_', $content);
964  $this->assertContains('type="radio" name="marketingListsManage' .
965  'SubscriptionListView-toggleUnsubscribed_', $content);
966  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
967  $marketingListIds[0] . '_1" checked="checked" type="radio" name="marketingListsManage' .
968  'SubscriptionListView-toggleUnsubscribed_' . $marketingListIds[0], $content);
969  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
970  $marketingListIds[1] . '_0" checked="checked" type="radio" name="marketingListsManage' .
971  'SubscriptionListView-toggleUnsubscribed_' . $marketingListIds[1], $content);
972  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
973  $marketingListIds[2] . '_1" checked="checked" type="radio" name="marketingListsManage' .
974  'SubscriptionListView-toggleUnsubscribed_' . $marketingListIds[2], $content);
975  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
976  $marketingListIds[3] . '_0" checked="checked" type="radio" name="marketingListsManage' .
977  'SubscriptionListView-toggleUnsubscribed_' . $marketingListIds[3], $content);
978  @$this->runControllerWithRedirectExceptionAndGetUrl($this->optOutUrl);
979  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
980  $this->assertContains('<td>marketingList 01</td>', $content);
981  $this->assertContains('<td>marketingList 03</td>', $content);
982  $this->assertNotContains('<td>marketingList 02</td>', $content);
983  $this->assertNotContains('<td>marketingList 04</td>', $content);
984  $this->assertContains('marketingLists/external/subscribe?hash=', $content);
985  $this->assertContains('id="marketingListsManage' .
986  'SubscriptionListView-toggleUnsubscribed_', $content);
987  $this->assertContains('id="marketingListsManage' .
988  'SubscriptionListView-toggleUnsubscribed_', $content);
989  $this->assertContains('type="radio" name="marketingListsManage' .
990  'SubscriptionListView-toggleUnsubscribed_', $content);
991  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
992  $marketingListIds[0] . '_1" checked="checked" type="radio" name="marketingListsManage' .
993  'SubscriptionListView-toggleUnsubscribed_' . $marketingListIds[0], $content);
994  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
995  $marketingListIds[2] . '_1" checked="checked" type="radio" name="marketingListsManage' .
996  'SubscriptionListView-toggleUnsubscribed_' . $marketingListIds[2], $content);
998  $contact = Contact::getByName('contact 05 contact 05son');
999  $this->assertNotEmpty($contact);
1000  $contact = $contact[0];
1001  $this->assertEquals(1, $contact->primaryEmail->optOut);
1002  }
1003 
1008  {
1010  $marketingList = MarketingList::getByName('marketingList 04');
1011  $this->assertNotEmpty($marketingList);
1012  $marketingList = $marketingList[0];
1013  $marketingListId = $marketingList->id;
1014  $contact = Contact::getByName('contact 05 contact 05son');
1015  $this->assertNotEmpty($contact);
1016  $contact = $contact[0];
1017  $this->assertEquals(1, $contact->primaryEmail->optOut);
1018  $personId = $contact->getClassId('Person');
1019  $member = MarketingListMember::getByMarketingListIdContactIdAndUnsubscribed($marketingList->id,
1020  $contact->id,
1021  1);
1022  $this->assertNotEmpty($member);
1023  Yii::app()->user->userModel = null;
1024  $hash = GlobalMarketingFooterUtil::resolveHash($personId, $marketingListId, 1,
1025  'AutoresponderItem', false);
1026  $this->setGetArray(array(
1027  'hash' => $hash,
1028  ));
1029  @$this->runControllerWithRedirectExceptionAndGetUrl($this->subscribeUrl);
1030  $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
1031  $this->assertContains('<td>marketingList 01</td>', $content);
1032  $this->assertContains('<td>marketingList 03</td>', $content);
1033  $this->assertContains('marketingLists/external/subscribe?hash=', $content);
1034  $this->assertContains('id="marketingListsManage' .
1035  'SubscriptionListView-toggleUnsubscribed_', $content);
1036  $this->assertContains('id="marketingListsManage' .
1037  'SubscriptionListView-toggleUnsubscribed_', $content);
1038  $this->assertContains('type="radio" name="marketingListsManage' .
1039  'SubscriptionListView-toggleUnsubscribed_', $content);
1040  $this->assertContains('id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' .
1041  $marketingListId. '_0" checked="checked" type="radio" name="marketingListsManage' .
1042  'SubscriptionListView-toggleUnsubscribed_' . $marketingListId, $content);
1044  $contact = Contact::getByName('contact 05 contact 05son');
1045  $this->assertNotEmpty($contact);
1046  $contact = $contact[0];
1047  $this->assertEquals(0, $contact->primaryEmail->optOut);
1048  }
1049 
1054  {
1055  $this->setGetArray(array(
1056  'hash' => 'HashDoesNotMatterHere',
1057  'preview' => 1,
1058  ));
1059  $content = $this->runControllerWithExitExceptionAndGetContent($this->unsubscribeUrl);
1060  $this->assertContains('<div class="GridView">', $content);
1061  $this->assertContains('<div id="MarketingListsExternalActionsPreviewView" ' .
1062  'class="splash-view SplashView">', $content);
1063  $this->assertContains('<div class="Warning">', $content);
1064  $this->assertContains('<h2>Not so fast!</h2>', $content);
1065  $this->assertContains('<div class="large-icon">', $content);
1066  $this->assertContains('<p>Access denied due to preview mode being active.</p>', $content);
1067  $this->assertContains('<footer id="FooterView">', $content);
1068  }
1069 
1074  {
1075  $this->setGetArray(array(
1076  'hash' => 'HashDoesNotMatterHere',
1077  'preview' => 1,
1078  ));
1079  $content = $this->runControllerWithExitExceptionAndGetContent($this->subscribeUrl);
1080  $this->assertContains('<div class="GridView">', $content);
1081  $this->assertContains('<div id="MarketingListsExternalActionsPreviewView" ' .
1082  'class="splash-view SplashView">', $content);
1083  $this->assertContains('<div class="Warning">', $content);
1084  $this->assertContains('<h2>Not so fast!</h2>', $content);
1085  $this->assertContains('<div class="large-icon">', $content);
1086  $this->assertContains('<p>Access denied due to preview mode being active.</p>', $content);
1087  $this->assertContains('<footer id="FooterView">', $content);
1088  }
1089 
1094  {
1095  $this->setGetArray(array(
1096  'hash' => 'HashDoesNotMatterHere',
1097  'preview' => 1,
1098  ));
1099  $content = $this->runControllerWithExitExceptionAndGetContent($this->optOutUrl);
1100  $this->assertContains('<div class="GridView">', $content);
1101  $this->assertContains('<div id="MarketingListsExternalActionsPreviewView" ' .
1102  'class="splash-view SplashView">', $content);
1103  $this->assertContains('<div class="Warning">', $content);
1104  $this->assertContains('<h2>Not so fast!</h2>', $content);
1105  $this->assertContains('<div class="large-icon">', $content);
1106  $this->assertContains('<p>Access denied due to preview mode being active.</p>', $content);
1107  $this->assertContains('<footer id="FooterView">', $content);
1108  }
1109 
1114  {
1115  $this->setGetArray(array(
1116  'hash' => 'HashDoesNotMatterHere',
1117  'preview' => 1,
1118  ));
1119  $content = $this->runControllerWithExitExceptionAndGetContent($this->manageSubscriptionsUrl);
1120  $this->assertContains('<div class="GridView">', $content);
1121  $this->assertContains('<div id="MarketingListsExternalActionsPreviewView" ' .
1122  'class="splash-view SplashView">', $content);
1123  $this->assertContains('<div class="Warning">', $content);
1124  $this->assertContains('<h2>Not so fast!</h2>', $content);
1125  $this->assertContains('<div class="large-icon">', $content);
1126  $this->assertContains('<p>Access denied due to preview mode being active.</p>', $content);
1127  $this->assertContains('<footer id="FooterView">', $content);
1128  }
1129  }
1130 ?>
static rebuild($overwriteExistingTables=true, $forcePhp=false, $messageStreamer=null)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
Generated on Sat Jul 11 2020 07:10:31
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.