Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
CampaignDefaultControllerSuperUserWalkthroughTest.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 $user;
40 
41  protected $campaign;
42 
43  public static function setUpBeforeClass()
44  {
45  parent::setUpBeforeClass();
46  SecurityTestHelper::createSuperAdmin();
47  $super = User::getByUsername('super');
48  Yii::app()->user->userModel = $super;
49 
50  EmailTemplateTestHelper::create('EmailTemplate 01', 'Subject 01', 'Contact', 'html', 'text');
51  EmailTemplateTestHelper::create('EmailTemplate 02', 'Subject 02', 'Contact', 'html', 'text');
52  EmailTemplateTestHelper::create('EmailTemplate 03', 'Subject 03', 'Contact', 'html', 'text');
53  MarketingListTestHelper::createMarketingListByName('MarketingListName',
54  'MarketingList Description',
55  'first',
56  'first@zurmo.com');
57  }
58 
59  public function setUp()
60  {
61  parent::setUp();
62  $this->user = User::getByUsername('super');
63  Yii::app()->user->userModel = $this->user;
64  $campaigns = Campaign::getAll();
65  if (count($campaigns) > 0)
66  {
67  $this->campaign = $campaigns[0];
68  }
69  }
70 
71  public function testSuperUserAllDefaultControllerActions()
72  {
73  // Test all default controller actions that do not require any POST/GET variables to be passed.
74  $this->runControllerWithNoExceptionsAndGetContent('campaigns/default');
75  $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/index');
76  $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
77  CampaignTestHelper::createCampaign('campaign01',
78  'campaign subject 01',
79  'text content for campaign 01',
80  'html content for campaign 01',
81  'fromCampaign',
82  'fromCampaign@zurmo.com');
83  CampaignTestHelper::createCampaign('campaign02',
84  'campaign subject 02',
85  'text content for campaign 02',
86  'html content for campaign 02',
87  'fromCampaign2',
88  'fromCampaign2@zurmo.com');
89 
90  $this->runControllerWithNoExceptionsAndGetContent('campaigns/default');
91  $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/index');
92  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
93  $compareContent = 'Campaigns will not run properly until scheduled jobs are set up. Contact your administrator.';
94  $this->assertNotContains($compareContent, $content);
95  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/create');
96  $compareContent = 'Campaigns will not run properly until scheduled jobs are set up. Contact your administrator.';
97  $this->assertContains($compareContent, $content);
98  }
99 
104  {
105  $jobLog = new JobLog();
106  $jobLog->type = 'CampaignGenerateDueCampaignItems';
107  $jobLog->startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
108  $jobLog->endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
109  $jobLog->status = JobLog::STATUS_COMPLETE_WITHOUT_ERROR;
110  $jobLog->isProcessed = false;
111  $this->assertTrue($jobLog->save());
112 
113  $jobLog = new JobLog();
114  $jobLog->type = 'CampaignMarkCompleted';
115  $jobLog->startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
116  $jobLog->endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
117  $jobLog->status = JobLog::STATUS_COMPLETE_WITHOUT_ERROR;
118  $jobLog->isProcessed = false;
119  $this->assertTrue($jobLog->save());
120 
121  $jobLog = new JobLog();
122  $jobLog->type = 'CampaignQueueMessagesInOutbox';
123  $jobLog->startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
124  $jobLog->endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
125  $jobLog->status = JobLog::STATUS_COMPLETE_WITHOUT_ERROR;
126  $jobLog->isProcessed = false;
127  $this->assertTrue($jobLog->save());
128 
129  $jobLog = new JobLog();
130  $jobLog->type = 'ProcessOutboundEmail';
131  $jobLog->startDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
132  $jobLog->endDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
133  $jobLog->status = JobLog::STATUS_COMPLETE_WITHOUT_ERROR;
134  $jobLog->isProcessed = false;
135  $this->assertTrue($jobLog->save());
136 
137  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/create');
138  $compareContent = 'Campaigns will not run properly until scheduled jobs are set up. Contact your administrator.';
139  $this->assertNotContains($compareContent, $content);
140  }
141 
145  public function testSuperUserListAction()
146  {
147  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
148  $this->assertContains('anyMixedAttributes', $content);
149  $this->assertContains('campaign01', $content);
150  $this->assertContains('campaign02', $content);
151  $this->assertContains('Scheduled', $content);
152  //Test the search or paging of the listview.
153  Yii::app()->clientScript->reset(); //to make sure old js doesn't make it to the UI
154  $this->setGetArray(array('ajax' => 'list-view'));
155  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
156  $this->assertNotContains('anyMixedAttributes', $content);
157  }
158 
163  {
164  StickyReportUtil::clearDataByKey('CampaignsSearchForm');
165  $this->setGetArray(array(
166  'CampaignsSearchForm' => array(
167  'anyMixedAttributesScope' => array('All'),
168  'anyMixedAttributes' => 'xyz',
169  ) ,
170  ));
171  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
172  $this->assertContains('No results found', $content);
173 
174  StickyReportUtil::clearDataByKey('CampaignsSearchForm');
175  $this->setGetArray(array(
176  'CampaignsSearchForm' => array(
177  'anyMixedAttributesScope' => array('All'),
178  'anyMixedAttributes' => 'camp',
179  ) ,
180  ));
181  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
182  $this->assertContains('2 result(s)', $content);
183  $this->assertContains('Status</a></th>', $content);
184  $this->assertEquals(1, substr_count($content, 'campaign01'));
185  $this->assertEquals(1, substr_count($content, 'campaign02'));
186  $this->assertEquals(2, substr_count($content, 'Scheduled'));
187 
188  StickyReportUtil::clearDataByKey('CampaignsSearchForm');
189  $this->setGetArray(array(
190  'CampaignsSearchForm' => array(
191  'anyMixedAttributesScope' => array('All'),
192  'anyMixedAttributes' => 'campaign',
193  'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName'),
194  ) ,
195  ));
196  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
197  $this->assertContains('2 result(s)', $content);
198  $this->assertContains('Status</a></th>', $content);
199  $this->assertEquals(1, substr_count($content, 'campaign01'));
200  $this->assertEquals(1, substr_count($content, 'campaign02'));
201  $this->assertEquals(2, substr_count($content, 'Scheduled'));
202  $this->assertEquals(3, substr_count($content, 'Clark Kent'));
203  $this->assertEquals(4, substr_count($content, '@zurmo.com'));
204  $this->assertEquals(6, substr_count($content, 'fromCampaign'));
205  $this->assertEquals(3, substr_count($content, 'fromCampaign2'));
206  $this->assertEquals(2, substr_count($content, 'fromCampaign@zurmo.com'));
207  $this->assertEquals(2, substr_count($content, 'fromCampaign2@zurmo.com'));
208 
209  StickyReportUtil::clearDataByKey('CampaignsSearchForm');
210  $this->setGetArray(array(
211  'clearingSearch' => 1,
212  'CampaignsSearchForm' => array(
213  'anyMixedAttributesScope' => array('All'),
214  'anyMixedAttributes' => '',
215  'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName'),
216  'dynamicClauses' => array(array(
217  'attributeIndexOrDerivedType' => 'fromAddress',
218  'structurePosition' => 1,
219  'fromAddress' => 'fromCampaign2@zurmo.com',
220  )),
221  'dynamicStructure' => '1',
222  ) ,
223  ));
224  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
225  $this->assertContains('1 result(s)', $content);
226  $this->assertContains('Status</a></th>', $content);
227  $this->assertEquals(1, substr_count($content, 'campaign02'));
228  $this->assertEquals(1, substr_count($content, 'Scheduled'));
229  $this->assertEquals(2, substr_count($content, 'Clark Kent'));
230  $this->assertEquals(2, substr_count($content, '@zurmo.com'));
231  $this->assertEquals(8, substr_count($content, 'fromCampaign2'));
232  $this->assertEquals(2, substr_count($content, 'fromCampaign2@zurmo.com'));
233 
234  StickyReportUtil::clearDataByKey('CampaignsSearchForm');
235  $this->setGetArray(array(
236  'clearingSearch' => 1,
237  'CampaignsSearchForm' => array(
238  'anyMixedAttributesScope' => array('All'),
239  'anyMixedAttributes' => '',
240  'selectedListAttributes' => array('name', 'status', 'createdByUser', 'fromAddress', 'fromName'),
241  'dynamicClauses' => array(array(
242  'attributeIndexOrDerivedType' => 'fromName',
243  'structurePosition' => 1,
244  'fromName' => 'fromCampaign2',
245  )),
246  'dynamicStructure' => '1',
247  ) ,
248  ));
249  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/list');
250  $this->assertContains('1 result(s)', $content);
251  $this->assertContains('Status</a></th>', $content);
252  $this->assertEquals(1, substr_count($content, 'campaign02'));
253  $this->assertEquals(1, substr_count($content, 'Scheduled'));
254  $this->assertEquals(2, substr_count($content, 'Clark Kent'));
255  $this->assertEquals(2, substr_count($content, '@zurmo.com'));
256  $this->assertEquals(8, substr_count($content, 'fromCampaign2'));
257  $this->assertEquals(2, substr_count($content, 'fromCampaign2@zurmo.com'));
258  }
259 
263  public function testSuperUserCreateAction()
264  {
265  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/create');
266  $this->assertContains('<title>ZurmoCRM - Campaigns</title>', $content);
267  $this->assertContains('<div id="MarketingBreadCrumbView" class="BreadCrumbView">' .
268  '<div class="breadcrumbs">', $content);
269  $this->assertContains('<div class="AppContent GridView">', $content);
270  $this->assertContains('/marketing/default/index">Marketing</a>', $content);
271  $this->assertContains('/campaigns/default/list">Campaigns</a>', $content);
272  $this->assertContains('<span>Create</span></div></div>', $content);
273  $this->assertContains('<div id="CampaignEditView" class="SecuredEditView EditView DetailsView' .
274  ' ModelView ConfigurableMetadataView MetadataView">', $content);
275  $this->assertContains('<div class="wrapper">', $content);
276  $this->assertContains('<h1><span class="truncated-title"><span class="ellipsis-content">' .
277  'Create Campaign</span></span></h1>', $content);
278  $this->assertContains('<div class="wide form">', $content);
279  $this->assertContains('<div class="attributesContainer">', $content);
280  $this->assertContains('<div class="left-column"><div class="panel">', $content);
281  $this->assertContains('<tr><th><label for="Campaign_name" class="required">Name '.
282  '<span class="required">*</span></label></th>', $content);
283  $this->assertContains('<td colspan="1"><input id="Campaign_name" name="Campaign[name]" ' .
284  'type="text" maxlength="64"', $content);
285  $this->assertContains('</tr><tr><th><label for="Campaign_marketingList_id" class="required">' .
286  'Marketing List <span class="required">*</span></label></th>', $content);
287  $this->assertContains('<td colspan="1"><input name="Campaign[marketingList][id]" ' .
288  'id="Campaign_marketingList_id" value="" type="hidden"', $content);
289  $this->assertContains('<div class="has-model-select">', $content);
290  $this->assertContains('id="Campaign_marketingList_name" type="text" value="" '.
291  'name="Campaign_marketingList_name"', $content);
292  $this->assertContains('<a id="Campaign_marketingList_SelectLink" href="#"><span class="' .
293  'model-select-icon"></span><span class="z-spinner"></span></a>', $content);
294  $this->assertContains('<tr><th><label for="Campaign_fromName" class="required">From Name ' .
295  '<span class="required">*</span></label></th>', $content);
296  $this->assertContains('<td colspan="1"><input id="Campaign_fromName" name="Campaign[fromName]" ' .
297  'type="text" maxlength="64"', $content);
298  $this->assertContains('<tr><th><label for="Campaign_fromAddress" class="required">From Address ' .
299  '<span class="required">*</span></label></th>', $content);
300  $this->assertContains('<td colspan="1"><input id="Campaign_fromAddress" ' .
301  'name="Campaign[fromAddress]" type="text" maxlength="64"', $content);
302  $this->assertContains('<tr><th><label for="Campaign_sendOnDateTime" class="required">Send On ' .
303  '<span class="required">*</span></label></th>', $content);
304  $this->assertContains('<td colspan="1"><div class="has-date-select"><input ' .
305  'id="Campaign_sendOnDateTime" name="Campaign[sendOnDateTime]" ' .
306  'style="position:relative;z-index:10000;" type="text" ', $content);
307  $this->assertContains('</tr><tr><th><label for="Campaign_subject" class="required">Subject ' .
308  '<span class="required">*</span></label></th>', $content);
309  $this->assertContains('<td colspan="1"><input id="Campaign_subject" name="Campaign[subject]" ' .
310  'type="text" maxlength="255"', $content);
311  $this->assertContains('<tr><th>Enable Tracking<span id="enable-tracking-tooltip" ' .
312  'class="tooltip" title="Check to track when recipients open ' .
313  'an email or click any links.">?</span></th>', $content);
314  $this->assertContains('<td colspan="1"><input id="ytCampaign_enableTracking" type="hidden" ' .
315  'value="0" name="Campaign[enableTracking]"', $content);
316  $this->assertContains('<label class="hasCheckBox c_on"><input id="Campaign_enableTracking" ' .
317  'name="Campaign[enableTracking]" value="1" checked="checked" ' .
318  'type="checkbox"', $content);
319  $this->assertContains('<tr><th>Support HTML<span id="support-rich-text-tooltip" ' .
320  'class="tooltip" title="When checked, email will be sent in both text' .
321  ' and HTML format. Uncheck to only send text emails">' .
322  '?</span></th>', $content);
323  $this->assertContains('<td colspan="1"><input id="ytCampaign_supportsRichText" type="hidden"' .
324  ' value="0" name="Campaign[supportsRichText]"', $content);
325  $this->assertContains('<label class="hasCheckBox c_on"><input id="Campaign_supportsRichText"' .
326  ' name="Campaign[supportsRichText]" value="1" checked="checked"' .
327  ' type="checkbox"', $content);
328  $this->assertContains('<tr><th><label for="Campaign_contactEmailTemplateNames_name">Select a template</label></th>', $content);
329  $this->assertContains('<td colspan="1"><div class="has-model-select"><input name=""' .
330  ' id="Campaign_contactEmailTemplateNames_id"' .
331  ' value="" type="hidden" />', $content);
332  $this->assertContains('<input onblur="clearIdFromAutoCompleteField($(this).val(), &#039;' .
333  'Campaign_contactEmailTemplateNames_id&#039;);" id="Campaign_contact' .
334  'EmailTemplateNames_name" type="text" value="" ' .
335  'name="" />', $content);
336  $this->assertContains('<a id="Campaign_contactEmailTemplateNames_SelectLink" href="#">' .
337  '<span class="model-select-icon"></span><span class="z-spinner">' .
338  '</span></a></div></td></tr>', $content);
339  $this->assertContains('<tr><th><label>Attachments</label></th>', $content);
340  $this->assertContains('<div class="fileupload-buttonbar clearfix">', $content);
341  $this->assertContains('<div class="addfileinput-button"><span>Y</span>', $content);
342  $this->assertContains('<strong class="add-label">Add Files</strong>', $content);
343  $this->assertContains('<input id="Campaign_files" multiple="multiple" type="file" name="Campaign_files"', $content);
344  $this->assertContains('<div class="fileupload-content">', $content);
345  $this->assertContains('<table class="files">', $content);
346  $this->assertContains('<div class="right-column">', $content);
347  $this->assertContains('<div class="email-template-combined-content', $content);
348  $this->assertContains('<div class="email-template-content"><div class="tabs-nav">', $content);
349  $this->assertContains('<a href="#tab1">Text Content</a>', $content);
350  $this->assertContains('<a class="active-tab" href="#tab2">Html Content</a>', $content);
351  $this->assertContains('class="simple-link" href="#">MergeTag Guide</a></div>', $content);
352  $this->assertContains('<div id="tab1" class=" tab email-template-textContent">', $content);
353  $this->assertContains('<th><label for="Campaign_textContent">Text Content</label></th>', $content);
354  $this->assertContains('<td colspan="1"><textarea id="Campaign_textContent" ' .
355  'name="Campaign[textContent]" rows="6" cols="50">' .
356  '</textarea></td></div>', $content);
357  $this->assertContains('<div id="tab2" class="active-tab tab email-template-htmlContent">' .
358  '<label for="Campaign_htmlContent">Html Content</label>', $content);
359  $this->assertContains('<textarea id="Campaign_htmlContent" name="Campaign[htmlContent]"', $content);
360  $this->assertContains('<div class="float-bar"><div class="view-toolbar-container ' .
361  'clearfix dock"><div class="form-toolbar">', $content);
362  $this->assertContains('/campaigns/default"><span class="z-label">Cancel</span></a>', $content);
363  $this->assertContains('Save and Schedule', $content);
364  $this->assertContains('<div id="modalContainer-edit-form">', $content);
365 
366  $this->setPostArray(array('Campaign' => array(
367  'name' => '',
368  'marketingList' => array('id' => ''),
369  'fromName' => '',
370  'fromAddress' => '',
371  'sendOnDateTime' => '',
372  'subject' => '',
373  'enableTracking' => '',
374  'supportsRichText' => '',
375  'textContent' => '',
376  'htmlContent' => '',
377  )));
378  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/create');
379  $this->assertContains('<div class="errorSummary"><p>Please fix the following' .
380  ' input errors:</p>', $content);
381  $this->assertContains('<li>Name cannot be blank.</li>', $content);
382  $this->assertEquals(1, substr_count($content, '<li>Name cannot be blank.</li>'));
383  $this->assertContains('<li>Marketing List cannot be blank.</li>', $content);
384  $this->assertContains('<li>Supports HTML cannot be blank.</li>', $content);
385  $this->assertContains('<li>Send On cannot be blank.</li>', $content);
386  $this->assertContains('<li>From Name cannot be blank.</li>', $content);
387  $this->assertContains('<li>From Address cannot be blank.</li>', $content);
388  $this->assertContains('<li>Subject cannot be blank.</li>', $content);
389  $this->assertContains('<li>Please provide at least one of the contents field.</li>', $content);
390  $this->assertContains('<tr><th><label class="error required" for="Campaign_name">Name ' .
391  '<span class="required">*</span></label></th>', $content);
392  $this->assertContains('<td colspan="1"><input id="Campaign_name" name="Campaign[name]" ' .
393  'type="text" maxlength="64" value="" class="error"', $content);
394  $this->assertContains('<tr><th><label class="error required" for="Campaign_marketingList_id">' .
395  'Marketing List <span class="required">*</span></label></th>', $content);
396  $this->assertContains('<tr><th><label class="error required" for="Campaign_fromName">From Name' .
397  ' <span class="required">*</span></label></th>', $content);
398  $this->assertContains('<td colspan="1"><input id="Campaign_fromName" name="Campaign[fromName]"' .
399  ' type="text" maxlength="64" value="" class="error"', $content);
400  $this->assertContains('<tr><th><label class="error required" for="Campaign_fromAddress">From' .
401  ' Address <span class="required">*</span></label></th>', $content);
402  $this->assertContains('<td colspan="1"><input id="Campaign_fromAddress" name="Campaign' .
403  '[fromAddress]" type="text" maxlength="64" ' .
404  'value="" class="error"', $content);
405  $this->assertContains('<tr><th><label class="error required" for="Campaign_sendOnDateTime">' .
406  'Send On <span class="required">*</span></label></th>', $content);
407  $this->assertContains('<tr><th><label class="error required" for="Campaign_subject">Subject ' .
408  '<span class="required">*</span></label></th>', $content);
409  $this->assertContains('<td colspan="1"><input id="Campaign_subject" name="Campaign[subject]" '.
410  'type="text" maxlength="255" value="" class="error"', $content);
411  $this->assertContains('<input id="Campaign_supportsRichText" name="Campaign[supportsRichText]"' .
412  ' value="1" type="checkbox" class="error"', $content);
413 
414  $marketingListId = self::getModelIdByModelNameAndName('MarketingList', 'MarketingListName');
415  $this->setPostArray(array('Campaign' => array(
416  'name' => 'New Campaign using Create',
417  'marketingList' => array('id' => $marketingListId),
418  'fromName' => 'Zurmo Sales',
419  'fromAddress' => 'sales@zurmo.com',
420  'sendOnDateTime' => '6/13/2013 10:54 AM',
421  'subject' => 'New Campaign using Create Subject',
422  'enableTracking' => '1',
423  'supportsRichText' => '0',
424  'textContent' => 'Text',
425  'htmlContent' => 'Html',
426  )));
427  $redirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('campaigns/default/create');
428  $campaign = Campaign::getByName('New Campaign using Create');
429  $this->assertEquals(1, count($campaign));
430  $this->assertTrue ($campaign[0]->id > 0);
431  $this->assertEquals('sales@zurmo.com', $campaign[0]->fromAddress);
432  $this->assertEquals('Zurmo Sales', $campaign[0]->fromName);
433  $this->assertEquals('New Campaign using Create Subject', $campaign[0]->subject);
434  $this->assertEquals('1', $campaign[0]->enableTracking);
435  $this->assertEquals('0', $campaign[0]->supportsRichText);
436  $this->assertEquals('Text', $campaign[0]->textContent);
437  $this->assertEquals('Html', $campaign[0]->htmlContent);
438  $this->assertEquals(DateTimeUtil::convertTimestampToDbFormatDateTime(strtotime('6/13/13 10:54 AM')),
439  $campaign[0]->sendOnDateTime);
440  $this->assertEquals($marketingListId, $campaign[0]->marketingList->id);
441  $this->assertTrue ($campaign[0]->owner == $this->user);
442  $compareRedirectUrl = Yii::app()->createUrl('campaigns/default/details', array('id' => $campaign[0]->id));
443  $this->assertEquals($compareRedirectUrl, $redirectUrl);
444  $campaigns = Campaign::getAll();
445  $this->assertEquals(3, count($campaigns));
446  }
447 
451  public function testSuperUserDetailsAction()
452  {
453  $campaignId = self::getModelIdByModelNameAndName ('Campaign', 'New Campaign using Create');
454  $this->setGetArray(array('id' => $campaignId));
455  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/details');
456  $this->assertContains('<title>ZurmoCRM - Campaigns</title>', $content);
457  $this->assertContains('<div id="MarketingStickyDetailsAndRelationsBreadCrumbView" ' .
458  'class="StickyDetailsAndRelationsBreadCrumbView ' .
459  'BreadCrumbView">', $content);
460  $this->assertContains('<div class="breadcrumbs">', $content);
461  $this->assertContains('/marketing/default/index">Marketing</a>', $content);
462  $this->assertContains('/campaigns/default/list">Campaigns</a>', $content);
463  $this->assertContains('<span>New Campaign using Create</span></div></div>', $content);
464  $this->assertContains('<div id="CampaignDetailsAndRelationsView" class="single-column ' .
465  'DetailsAndRelationsView ConfigurableMetadataView' .
466  ' MetadataView">', $content);
467  $this->assertContains('<div class="GridView">', $content);
468  $this->assertContains('<div id="CampaignDetailsView" class="SecuredDetailsView DetailsView ' .
469  'ModelView ConfigurableMetadataView MetadataView">', $content);
470  $this->assertContains('<h1><span class="truncated-title"><span class="ellipsis-content">New '.
471  'Campaign using Create - Campaign</span></span></h1>', $content);
472  $this->assertContains('<div class="view-toolbar-container clearfix"><nav class="pillbox clearfix">' .
473  '<div id="ListViewDetailsActionMenu" class="default-button">', $content);
474  $this->assertContains('<div id="CampaignDetailsOverlayView" class="overlay-view SecuredDetailsView '.
475  'DetailsView ModelView ConfigurableMetadataView '.
476  'MetadataView">', $content);
477  $this->assertContains('<div class="campaign-description"><strong>Send On: 6/13/13 ' .
478  '10:54 AM</strong>', $content);
479  $this->assertContains('<strong>Subject: New Campaign using Create Subject</strong></div>', $content);
480  $this->assertContains('<p class="after-form-details-content">', $content);
481  $this->assertContains('EditLinkActionElement', $content);
482  $this->assertContains('CampaignDeleteLinkActionElement', $content);
483  $this->assertContains('<div class="ModelRelationsSecuredPortletFrameView SecuredPortlet' .
484  'FrameView PortletFrameView MetadataView">', $content);
485  $this->assertContains('<div class="juiportlet-columns"> ', $content);
486  $this->assertContains('<ul class="juiportlet-columns-CampaignDetailsAndRelationsViewLeft' .
487  'BottomView juiportlet-widget-column1 juiportlet-column juiportlet-column-no-split">', $content);
488  $this->assertContains('<li class="juiportlet-widget CampaignOverallMetricsView type-campaigns" id="Campaign' .
489  'DetailsAndRelationsViewLeftBottomView', $content);
490  $this->assertContains('<div class="juiportlet-widget-head">', $content);
491  $this->assertContains('<h3>Campaign Dashboard</h3><div class="portlet-actions-container"><ul class="options-menu '.
492  'edit-portlet-menu nav">', $content);
493  $this->assertContains('<li class="parent last"><a href="javascript:void(0);">' .
494  '<span></span></a>', $content);
495  $this->assertContains('<li class="last"><a class="edit" id="CampaignDetailsAndRelations' .
496  'ViewLeftBottomView', $content);
497  $this->assertContains('" href="#"><span>Configure Portlet</span></a></li>', $content);
498  $this->assertContains('<div class="juiportlet-widget-content" >', $content);
499  $this->assertContains('<div id="CampaignOverallMetricsView" class="MarketingMetricsView ' .
500  'ConfigurableMetadataView MetadataView">', $content);
501  $this->assertContains('<div class="left-column full-width metrics-details ' .
502  'campaign-metrics-container">', $content);
503  $this->assertContains('<h3>What is going on with this campaign?</h3>', $content);
504  $this->assertContains('<form id="marketing-metrics-group-by-configuration-form-CampaignDetails' .
505  'AndRelationsViewLeftBottomView', $content);
506  $this->assertContains('action="/app/test/index.php/somewhereForTheTest" ' .
507  'method="post">', $content);
508  $this->assertContains('<div id="marketing-metrics-group-by-configuration-form-CampaignDetails' .
509  'AndRelationsViewLeftBottomView', $content);
510  $this->assertContains('<th><label for="ytMarketingOverallMetricsForm_groupBy">Group By' .
511  '</label></th>', $content);
512  $this->assertContains('<td colspan="1"><input type="hidden" value="" name="marketingMetrics' .
513  'GroupByNotUsedName" id="marketingMetricsGroupByNotUsedName"', $content);
514  $this->assertContains('<div class="pills"><a data-value="Day" class="marketing-metrics-group-' .
515  'by-configuration-form-CampaignDetailsAnd' .
516  'RelationsViewLeftBottomView', $content);
517  $this->assertContains('<a data-value="Week" class="marketing-metrics-group-by-configuration-'.
518  'form-CampaignDetailsAndRelationsViewLeftBottomView', $content);
519  $this->assertContains('marketingMetricsGroupByLink active" href="#">Week</a>', $content);
520  $this->assertContains('<a data-value="Month" class="marketing-metrics-group-by-configuration' .
521  '-form-CampaignDetailsAndRelationsViewLeftBottomView', $content);
522  $this->assertContains('marketingMetricsGroupByLink" href="#">Month</a></div>', $content);
523  $this->assertContains('<div class="graph-container clearfix">', $content);
524  $this->assertContains('<div class="half marketing-graph">', $content);
525  $this->assertContains('<h3>Overall Campaign Performance</h3>', $content);
526  $this->assertContains("<div id='chartContainerCampaignDetailsAndRelationsView" .
527  "LeftBottomView", $content);
528  $this->assertContains("OverallListPerformance' style='width: 100%; " .
529  "height: 400px;'></div>", $content);
530  $this->assertContains('<h3>Emails in this Campaign</h3>', $content);
531  $this->assertContains("<div id='chartContainerCampaignDetailsAndRelationsView" .
532  "LeftBottomView", $content);
533  $this->assertContains("EmailsInThisList' style='width: 100%; " .
534  "height: 400px;'></div>", $content);
535  $this->assertContains('<li class="juiportlet-widget CampaignItemsRelatedListView type-campaigns" ' .
536  'id="CampaignDetailsAndRelationsViewLeftBottomView', $content);
537  $this->assertContains('<div class="juiportlet-widget-head">', $content);
538  $this->assertContains('<h3>Email Recipients</h3>', $content);
539  $this->assertContains('<div class="juiportlet-widget-content" ', $content);
540  $this->assertContains('<div class="CampaignItemsRelatedListView RelatedListView ListView ' .
541  'ModelView ConfigurableMetadataView MetadataView">', $content);
542  $this->assertContains('<div class="campaign-items-container">', $content);
543  $this->assertContains('<div class="cgrid-view type-campaigns" id="list-viewCampaignDetailsAndRelations' .
544  'ViewLeftBottomView', $content);
545  $this->assertContains('Email recipients will appear here once the campaign begins ' .
546  'sending out', $content);
547  }
548 
552  public function testSuperUserEditAction()
553  {
554  $campaigns = Campaign::getAll();
555  $this->assertEquals(3, count($campaigns));
556  $marketingListId = self::getModelIdByModelNameAndName('MarketingList', 'MarketingListName');
557  $campaignId = self::getModelIdByModelNameAndName ('Campaign', 'New Campaign using Create');
558  $this->setGetArray(array('id' => $campaignId));
559  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/edit');
560  $this->assertContains('<title>ZurmoCRM - Campaigns</title>', $content);
561  $this->assertContains('<div id="MarketingBreadCrumbView" class="BreadCrumbView">' .
562  '<div class="breadcrumbs">', $content);
563  $this->assertContains('/marketing/default/index">Marketing</a>', $content);
564  $this->assertContains('/campaigns/default/list">Campaigns</a>', $content);
565  $this->assertContains('<span>New Campaign using Create</span></div></div>', $content);
566  $this->assertContains('<div id="CampaignEditView" class="SecuredEditView EditView DetailsView' .
567  ' ModelView ConfigurableMetadataView MetadataView">', $content);
568  $this->assertContains('<h1><span class="truncated-title"><span class="ellipsis-content">New ' .
569  'Campaign using Create</span></span></h1>', $content);
570  $this->assertContains('<div class="wide form">', $content);
571  $this->assertContains('<div class="attributesContainer">', $content);
572  $this->assertContains('<div class="left-column"><div class="panel">', $content);
573  $this->assertContains('<th><label for="Campaign_name" class="required">Name <span class=' .
574  '"required">*</span></label></th>', $content);
575  $this->assertContains('<td colspan="1"><input id="Campaign_name" name="Campaign[name]" ' .
576  'type="text" maxlength="64" value="New Campaign using Create"', $content);
577  $this->assertContains('<th><label for="Campaign_marketingList_id" class="required">Marketing ' .
578  'List <span class="required">*</span></label></th>', $content);
579  $this->assertContains('<td colspan="1"><input name="Campaign[marketingList][id]" ' .
580  'id="Campaign_marketingList_id" value="' . $marketingListId .
581  '" type="hidden"', $content);
582  $this->assertContains('<a id="Campaign_marketingList_SelectLink" href="#"><span ' .
583  'class="model-select-icon"></span>', $content);
584  $this->assertContains('<th><label for="Campaign_fromName" class="required">From Name ' .
585  '<span class="required">*</span></label></th>', $content);
586  $this->assertContains('<td colspan="1"><input id="Campaign_fromName" name="Campaign[fromName]" ' .
587  'type="text" maxlength="64" value="Zurmo Sales"', $content);
588  $this->assertContains('<th><label for="Campaign_fromAddress" class="required">From Address ' .
589  '<span class="required">*</span></label></th>', $content);
590  $this->assertContains('<td colspan="1"><input id="Campaign_fromAddress" ' .
591  'name="Campaign[fromAddress]" type="text" maxlength="64" ' .
592  'value="sales@zurmo.com"', $content);
593  $this->assertContains('<th><label for="Campaign_sendOnDateTime" class="required">Send On ' .
594  '<span class="required">*</span></label></th>', $content);
595  $this->assertContains('<td colspan="1"><div class="has-date-select"><input ' .
596  'id="Campaign_sendOnDateTime" name="Campaign[sendOnDateTime]" ' .
597  'style="position:relative;z-index:10000;" type="text" ' .
598  'value="6/13/2013 10:54 AM"', $content);
599  $this->assertContains('<th><label for="Campaign_subject" class="required">Subject ' .
600  '<span class="required">*</span></label></th>', $content);
601  $this->assertContains('<td colspan="1"><input id="Campaign_subject" name="Campaign[subject]" ' .
602  'type="text" maxlength="255" value="New Campaign ' .
603  'using Create Subject"', $content);
604  $this->assertContains('<tr><th>Enable Tracking<span id="enable-tracking-tooltip" ' .
605  'class="tooltip" title="Check to track when recipients open ' .
606  'an email or click any links.">?</span></th>', $content);
607  $this->assertContains('<td colspan="1"><input id="ytCampaign_enableTracking" type="hidden" ' .
608  'value="0" name="Campaign[enableTracking]"', $content);
609  $this->assertContains('<label class="hasCheckBox c_on"><input id="Campaign_enableTracking" ' .
610  'name="Campaign[enableTracking]" value="1" checked="checked" ' .
611  'type="checkbox"', $content);
612  $this->assertContains('<th>Support HTML<span id="support-rich-text-tooltip" class="tooltip" '.
613  'title="When checked, email will be sent in both text and HTML format. ' .
614  ' Uncheck to only send text emails">?</span></th>', $content);
615  $this->assertContains('<td colspan="1"><input id="ytCampaign_supportsRichText" type="hidden" ' .
616  'value="0" name="Campaign[supportsRichText]"', $content);
617  $this->assertContains('<label class="hasCheckBox"><input id="Campaign_supportsRichText" ' .
618  'name="Campaign[supportsRichText]" value="1" type="checkbox"', $content);
619  $this->assertContains('<tr><th><label for="Campaign_contactEmailTemplateNames_name">Select a template</label></th>', $content);
620  $this->assertContains('<td colspan="1"><div class="has-model-select"><input name=""' .
621  ' id="Campaign_contactEmailTemplateNames_id"' .
622  ' value="" type="hidden" />', $content);
623  $this->assertContains('<input onblur="clearIdFromAutoCompleteField($(this).val(), &#039;' .
624  'Campaign_contactEmailTemplateNames_id&#039;);" id="Campaign_contact' .
625  'EmailTemplateNames_name" type="text" value="" ' .
626  'name="" />', $content);
627  $this->assertContains('<a id="Campaign_contactEmailTemplateNames_SelectLink" href="#">' .
628  '<span class="model-select-icon"></span><span class="z-spinner">' .
629  '</span></a></div></td></tr>', $content);
630  $this->assertContains('<th><label>Attachments</label></th>', $content);
631  $this->assertContains('<div class="fileupload-buttonbar clearfix">', $content);
632  $this->assertContains('<div class="addfileinput-button"><span>Y</span>', $content);
633  $this->assertContains('<strong class="add-label">Add Files</strong>', $content);
634  $this->assertContains('<input id="Campaign_files" multiple="multiple" type="file" name="Campaign_files"', $content);
635  $this->assertContains('<div class="fileupload-content"><table class="files">', $content);
636  $this->assertContains('<div class="right-column">', $content);
637  $this->assertContains('<div class="email-template-combined-content', $content);
638  $this->assertContains('<div class="email-template-content"><div class="tabs-nav">', $content);
639  $this->assertContains('<a href="#tab1">Text Content</a>', $content);
640  $this->assertContains('<a class="active-tab" href="#tab2">Html Content</a>', $content);
641  $this->assertContains('<div id="tab1" class=" tab email-template-' .
642  'textContent"><th>', $content);
643  $this->assertContains('<label for="Campaign_textContent">Text Content</label></th>', $content);
644  $this->assertContains('<td colspan="1"><textarea id="Campaign_textContent" ' .
645  'name="Campaign[textContent]" rows="6" cols="50">Text' .
646  '</textarea></td></div>', $content);
647  $this->assertContains('<div id="tab2" class="active-tab tab email-template-htmlContent">' .
648  '<label for="Campaign_htmlContent">Html Content</label>', $content);
649  $this->assertContains('<textarea id="Campaign_htmlContent" name="Campaign[htmlContent]"', $content);
650 
651  $marketingList = MarketingListTestHelper::createMarketingListByName('MarketingListName2',
652  'MarketingList Description',
653  'second',
654  'second@zurmo.com');
655  $this->setPostArray(array('Campaign' => array(
656  'name' => 'New Campaign',
657  'marketingList' => array('id' => $marketingList->id),
658  'fromName' => 'Zurmo Support',
659  'fromAddress' => 'support@zurmo.com',
660  'sendOnDateTime' => '5/14/2013 10:54 AM',
661  'subject' => 'New Campaign Subject',
662  'enableTracking' => '0',
663  'supportsRichText' => '1',
664  'textContent' => 'Text Content',
665  'htmlContent' => 'Html Content',
666  )));
667  $redirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('campaigns/default/edit');
668  $campaign = Campaign::getByName('New Campaign');
669  $this->assertEquals(1, count($campaign));
670  $this->assertTrue ($campaign[0]->id > 0);
671  $this->assertEquals('support@zurmo.com', $campaign[0]->fromAddress);
672  $this->assertEquals('Zurmo Support', $campaign[0]->fromName);
673  $this->assertEquals('New Campaign Subject', $campaign[0]->subject);
674  $this->assertEquals('0', $campaign[0]->enableTracking);
675  $this->assertEquals('1', $campaign[0]->supportsRichText);
676  $this->assertEquals('Text Content', $campaign[0]->textContent);
677  $this->assertEquals('Html Content', $campaign[0]->htmlContent);
678  $this->assertEquals(DateTimeUtil::convertTimestampToDbFormatDateTime(strtotime('5/14/13 10:54 AM')),
679  $campaign[0]->sendOnDateTime);
680  $this->assertEquals($marketingList->id, $campaign[0]->marketingList->id);
681  $this->assertEquals($campaign[0]->owner, $this->user);
682  $compareRedirectUrl = Yii::app()->createUrl('campaigns/default/details', array('id' => $campaign[0]->id));
683  $this->assertEquals($compareRedirectUrl, $redirectUrl);
684  $campaign = Campaign::getAll();
685  $this->assertEquals(3, count($campaign));
686  }
687 
688  public function testCampaignDashboardGroupByActions()
689  {
690  $this->assertNotNull($this->campaign);
691  $this->setGetArray(array('id' => $this->campaign->id));
692  $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/details');
693 
694  $portlets = Portlet::getAll();
695  foreach ($portlets as $portlet)
696  {
697  if ($portlet->viewType = 'MarketingListOverallMetrics')
698  {
699  $marketingListPortlet = $portlet;
700  }
701  }
702  $marketingLists = MarketingList::getAll();
703 
704  $this->setGetArray(array(
705  'portletId' => $portlet->id,
706  'uniqueLayoutId' => 'MarketingListDetailsAndRelationsViewLeftBottomView',
707  'portletParams' => array('relationModelId' => $marketingLists[0]->id,
708  'relationModuleId' => 'marketingLists',
709  ),
710  ));
711  $this->setPostArray(array(
712  'MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_DAY)
713  ));
714  $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave');
715  $this->setPostArray(array(
716  'MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_MONTH)
717  ));
718  $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave');
719  $this->setPostArray(array(
720  'MarketingOverallMetricsForm' => array('groupBy' => MarketingOverallMetricsForm::GROUPING_TYPE_WEEK)
721  ));
722  $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/modalConfigSave');
723  }
724 
728  public function testSuperUserDeleteAction()
729  {
730  $campaigns = Campaign::getAll();
731  $this->assertEquals(3, count($campaigns));
732  $this->setGetArray(array('id' => $campaigns[1]->id));
733  $this->resetPostArray();
734  $redirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('campaigns/default/delete');
735  $compareRedirectUrl = Yii::app()->createUrl('campaigns/default/index');
736  $this->assertEquals($redirectUrl, $compareRedirectUrl);
737  $campaigns = Campaign::getAll();
738  $this->assertEquals(2, count($campaigns));
739  }
740 
745  {
746  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
747  $campaigns = Campaign::getAll();
748  $this->assertEquals(2, count($campaigns));
749  $marketingList = MarketingListTestHelper::createMarketingListByName('my list');
750  //Create a new campaign from a related marketing list.
751  $this->setGetArray(array( 'relationAttributeName' => 'marketingList',
752  'relationModelId' => $marketingList->id,
753  'relationModuleId' => 'marketingLists',
754  'redirectUrl' => 'someRedirect'));
755  $this->setPostArray(array('Campaign' => array(
756  'name' => 'New Campaign using Create',
757  'fromName' => 'Zurmo Sales',
758  'fromAddress' => 'sales@zurmo.com',
759  'sendOnDateTime' => '6/13/2013 10:54 AM',
760  'subject' => 'New Campaign using Create Subject',
761  'enableTracking' => '1',
762  'supportsRichText' => '0',
763  'textContent' => 'Text',
764  'htmlContent' => 'Html',
765  )));
766  $this->runControllerWithRedirectExceptionAndGetContent('campaigns/default/createFromRelation');
767  $campaigns = Campaign::getByName('New Campaign using Create');
768  $this->assertEquals(1, count($campaigns));
769  $this->assertTrue($campaigns[0]->id > 0);
770  $this->assertTrue($campaigns[0]->owner == $super);
771  $this->assertTrue($campaigns[0]->marketingList->id == $marketingList->id);
772  $campaigns = Campaign::getAll();
773  $this->assertEquals(3, count($campaigns));
774  }
775 
779  public function testDrillDownDetailsAction()
780  {
781  $campaign = Campaign::getByName('campaign01');
782  $campaignItem = CampaignItemTestHelper::createCampaignItem(true, $campaign[0]);
783  $this->setGetArray(array('campaignItemId' => $campaignItem->id));
784  $content = $this->runControllerWithNoExceptionsAndGetContent('campaigns/default/drillDownDetails');
785  $this->assertNotNull($content);
786  }
787  }
788 ?>
static getByUsername($username)
Definition: User.php:49
runControllerWithRedirectExceptionAndGetContent($route, $compareUrl=null, $compareUrlContains=false)
static clearDataByKey($key)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null)
Generated on Tue Jul 7 2020 07:10:31
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.