Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
LeadsSuperUserWalkthroughTest.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 
44  {
45  public static function setUpBeforeClass()
46  {
47  parent::setUpBeforeClass();
48  SecurityTestHelper::createSuperAdmin();
49  $super = User::getByUsername('super');
50  Yii::app()->user->userModel = $super;
51 
52  //Setup test data owned by the super user.
53  LeadTestHelper::createLeadbyNameForOwner ('superLead', $super);
54  LeadTestHelper::createLeadbyNameForOwner ('superLead2', $super);
55  LeadTestHelper::createLeadbyNameForOwner ('superLead3', $super);
56  LeadTestHelper::createLeadbyNameForOwner ('superLead4', $super);
57  LeadTestHelper::createLeadbyNameForOwner ('superLead5', $super);
58  LeadTestHelper::createLeadbyNameForOwner ('superLead6', $super);
59  LeadTestHelper::createLeadbyNameForOwner ('superLead7', $super);
60  LeadTestHelper::createLeadbyNameForOwner ('superLead8', $super);
61  LeadTestHelper::createLeadbyNameForOwner ('superLead9', $super);
62  LeadTestHelper::createLeadbyNameForOwner ('superLead10', $super);
63  LeadTestHelper::createLeadbyNameForOwner ('superLead11', $super);
64  LeadTestHelper::createLeadbyNameForOwner ('superLead12', $super);
65  //Setup default dashboard.
66  Dashboard::getByLayoutIdAndUser (Dashboard::DEFAULT_USER_LAYOUT_ID, $super);
67  }
68 
69  public function testSuperUserAllDefaultControllerActions()
70  {
71  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
72 
73  //Test all default controller actions that do not require any POST/GET variables to be passed.
74  //This does not include portlet controller actions.
75  $this->runControllerWithNoExceptionsAndGetContent('leads/default');
76  $this->runControllerWithNoExceptionsAndGetContent('leads/default/index');
77  $this->runControllerWithNoExceptionsAndGetContent('leads/default/create');
78 
79  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/list');
80  $this->assertContains('anyMixedAttributes', $content);
81  //Test the search or paging of the listview.
82  Yii::app()->clientScript->reset(); //to make sure old js doesn't make it to the UI
83  $this->setGetArray(array('ajax' => 'list-view'));
84  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/list');
85  $this->assertNotContains('anyMixedAttributes', $content);
86  $this->resetGetArray();
87 
88  //Default Controller actions requiring some sort of parameter via POST or GET
89  //Load Model Edit Views
90  $leads = Contact::getAll();
91  $this->assertEquals(12, count($leads));
92  $superLeadId = self::getModelIdByModelNameAndName('Contact', 'superLead superLeadson');
93  $superLeadId2 = self::getModelIdByModelNameAndName('Contact', 'superLead2 superLead2son');
94  $superLeadId3 = self::getModelIdByModelNameAndName('Contact', 'superLead3 superLead3son');
95  $superLeadId4 = self::getModelIdByModelNameAndName('Contact', 'superLead4 superLead4son');
96  $superLeadId5 = self::getModelIdByModelNameAndName('Contact', 'superLead5 superLead5son');
97  $superLeadId6 = self::getModelIdByModelNameAndName('Contact', 'superLead6 superLead6son');
98  $superLeadId7 = self::getModelIdByModelNameAndName('Contact', 'superLead7 superLead7son');
99  $superLeadId8 = self::getModelIdByModelNameAndName('Contact', 'superLead8 superLead8son');
100  $superLeadId9 = self::getModelIdByModelNameAndName('Contact', 'superLead9 superLead9son');
101  $superLeadId10 = self::getModelIdByModelNameAndName('Contact', 'superLead10 superLead10son');
102  $superLeadId11 = self::getModelIdByModelNameAndName('Contact', 'superLead11 superLead11son');
103  $superLeadId12 = self::getModelIdByModelNameAndName('Contact', 'superLead12 superLead12son');
104  $this->setGetArray(array('id' => $superLeadId));
105  $this->runControllerWithNoExceptionsAndGetContent('leads/default/edit');
106  //Save lead.
107  $superLead = Contact::getById($superLeadId);
108  $this->assertEquals(null, $superLead->officePhone);
109  $this->setPostArray(array('Contact' => array('officePhone' => '456765421')));
110  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/edit');
111  $superLead = Contact::getById($superLeadId);
112  $this->assertEquals('456765421', $superLead->officePhone);
113  //Test having a failed validation on the lead during save.
114  $this->setGetArray (array('id' => $superLeadId));
115  $this->setPostArray(array('Contact' => array('lastName' => '')));
116  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/edit');
117  $this->assertContains('Name cannot be blank', $content);
118 
119  //Load Model Detail Views
120  $this->setGetArray(array('id' => $superLeadId));
121  $this->resetPostArray();
122  $this->runControllerWithNoExceptionsAndGetContent('leads/default/details');
123 
124  //Load Model MassEdit Views.
125  //MassEdit view for single selected ids
126  $this->setGetArray(array('selectedIds' => '4,5,6,7,8,9', 'selectAll' => '')); // Not Coding Standard
127  $this->resetPostArray();
128  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massEdit');
129  $this->assertContains('<strong>6</strong>&#160;records selected for updating', $content);
130 
131  //MassEdit view for all result selected ids
132  $leads = Contact::getAll();
133  $this->assertEquals(12, count($leads));
134  $this->setGetArray(array('selectAll' => '1'));
135  $this->resetPostArray();
136  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massEdit');
137  $this->assertContains('<strong>12</strong>&#160;records selected for updating', $content);
138  //save Model MassEdit for selected Ids
139  //Test that the 4 leads do not have the office phone number we are populating them with.
140  $lead1 = Contact::getById($superLeadId);
141  $lead2 = Contact::getById($superLeadId2);
142  $lead3 = Contact::getById($superLeadId3);
143  $lead4 = Contact::getById($superLeadId4);
144  $this->assertNotEquals('7788', $lead1->officePhone);
145  $this->assertNotEquals('7788', $lead2->officePhone);
146  $this->assertNotEquals('7788', $lead3->officePhone);
147  $this->assertNotEquals('7788', $lead4->officePhone);
148  $this->setGetArray(array(
149  'selectedIds' => $superLeadId . ',' . $superLeadId2, // Not Coding Standard
150  'selectAll' => '',
151  'Contact_page' => 1));
152  $this->setPostArray(array(
153  'Contact' => array('officePhone' => '7788'),
154  'MassEdit' => array('officePhone' => 1)
155  ));
156  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/massEdit');
157  //Test that the 2 leads have the new office phone number and the other contacts do not.
158  $lead1 = Contact::getById($superLeadId);
159  $lead2 = Contact::getById($superLeadId2);
160  $lead3 = Contact::getById($superLeadId3);
161  $lead4 = Contact::getById($superLeadId4);
162  $lead5 = Contact::getById($superLeadId5);
163  $lead6 = Contact::getById($superLeadId6);
164  $lead7 = Contact::getById($superLeadId7);
165  $lead8 = Contact::getById($superLeadId8);
166  $lead9 = Contact::getById($superLeadId9);
167  $lead10 = Contact::getById($superLeadId10);
168  $lead11 = Contact::getById($superLeadId11);
169  $lead12 = Contact::getById($superLeadId12);
170  $this->assertEquals ('7788', $lead1->officePhone);
171  $this->assertEquals ('7788', $lead2->officePhone);
172  $this->assertNotEquals('7788', $lead3->officePhone);
173  $this->assertNotEquals('7788', $lead4->officePhone);
174  $this->assertNotEquals('7788', $lead5->officePhone);
175  $this->assertNotEquals('7788', $lead6->officePhone);
176  $this->assertNotEquals('7788', $lead7->officePhone);
177  $this->assertNotEquals('7788', $lead8->officePhone);
178  $this->assertNotEquals('7788', $lead9->officePhone);
179  $this->assertNotEquals('7788', $lead10->officePhone);
180  $this->assertNotEquals('7788', $lead11->officePhone);
181  $this->assertNotEquals('7788', $lead12->officePhone);
182 
183  //save Model MassEdit for entire search result
184  $this->setGetArray(array(
185  'selectAll' => '1',
186  'Contact_page' => 1));
187  $this->setPostArray(array(
188  'Contact' => array('officePhone' => '1234'),
189  'MassEdit' => array('officePhone' => 1)
190  ));
191  $pageSize = Yii::app()->pagination->getForCurrentUserByType('massEditProgressPageSize');
192  $this->assertEquals(5, $pageSize);
193  Yii::app()->pagination->setForCurrentUserByType('massEditProgressPageSize', 20);
194  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/massEdit');
195  Yii::app()->pagination->setForCurrentUserByType('massEditProgressPageSize', $pageSize);
196  //Test that all accounts have the new phone number.
197  $lead1 = Contact::getById($superLeadId);
198  $lead2 = Contact::getById($superLeadId2);
199  $lead3 = Contact::getById($superLeadId3);
200  $lead4 = Contact::getById($superLeadId4);
201  $lead5 = Contact::getById($superLeadId5);
202  $lead6 = Contact::getById($superLeadId6);
203  $lead7 = Contact::getById($superLeadId7);
204  $lead8 = Contact::getById($superLeadId8);
205  $lead9 = Contact::getById($superLeadId9);
206  $lead10 = Contact::getById($superLeadId10);
207  $lead11 = Contact::getById($superLeadId11);
208  $lead12 = Contact::getById($superLeadId12);
209  $this->assertEquals('1234', $lead1->officePhone);
210  $this->assertEquals('1234', $lead2->officePhone);
211  $this->assertEquals('1234', $lead3->officePhone);
212  $this->assertEquals('1234', $lead4->officePhone);
213  $this->assertEquals('1234', $lead5->officePhone);
214  $this->assertEquals('1234', $lead6->officePhone);
215  $this->assertEquals('1234', $lead7->officePhone);
216  $this->assertEquals('1234', $lead8->officePhone);
217  $this->assertEquals('1234', $lead9->officePhone);
218  $this->assertEquals('1234', $lead10->officePhone);
219  $this->assertEquals('1234', $lead11->officePhone);
220  $this->assertEquals('1234', $lead12->officePhone);
221 
222  //Run Mass Update using progress save.
223  $pageSize = Yii::app()->pagination->getForCurrentUserByType('massEditProgressPageSize');
224  $this->assertEquals(5, $pageSize);
225  Yii::app()->pagination->setForCurrentUserByType('massEditProgressPageSize', 1);
226  //The page size is smaller than the result set, so it should exit.
227  $this->runControllerWithExitExceptionAndGetContent('leads/default/massEdit');
228  //save Modal MassEdit using progress load for page 2, 3 and 4.
229  $this->setGetArray(array('selectAll' => '1', 'Contact_page' => 2));
230  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massEditProgressSave');
231  $this->assertContains('"value":16', $content);
232  $this->setGetArray(array('selectAll' => '1', 'Contact_page' => 3));
233  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massEditProgressSave');
234  $this->assertContains('"value":25', $content);
235  $this->setGetArray(array('selectAll' => '1', 'Contact_page' => 4));
236  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massEditProgressSave');
237  $this->assertContains('"value":33', $content);
238  //Set page size back to old value.
239  Yii::app()->pagination->setForCurrentUserByType('massEditProgressPageSize', $pageSize);
240 
241  //Autocomplete for Lead
242  $this->setGetArray(array('term' => 'super'));
243  $this->runControllerWithNoExceptionsAndGetContent('leads/default/autoComplete');
244 
245  //actionModalList
246  $this->setGetArray(array(
247  'modalTransferInformation' => array('sourceIdFieldId' => 'x', 'sourceNameFieldId' => 'y', 'modalId' => 'z')
248  ));
249  $this->runControllerWithNoExceptionsAndGetContent('leads/default/modalList');
250 
251  //actionAuditEventsModalList
252  $this->setGetArray(array('id' => $superLeadId));
253  $this->resetPostArray();
254  $this->runControllerWithNoExceptionsAndGetContent('leads/default/auditEventsModalList');
255  }
256 
261  {
262  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
263  $superLeadId4 = self::getModelIdByModelNameAndName('Contact', 'superLead4 superLead4son');
264 
265  //Save a layout change. Collapse all portlets in the Lead Details View.
266  //At this point portlets for this view should be created because we have already loaded the 'details' page in a request above.
267  $portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition(
268  'LeadDetailsAndRelationsView', $super->id, array());
269  $this->assertEquals(3, count($portlets[1]));
270  $this->assertFalse(array_key_exists(3, $portlets) );
271  $portletPostData = array();
272  $portletCount = 0;
273  foreach ($portlets as $column => $columnPortlets)
274  {
275  foreach ($columnPortlets as $position => $portlet)
276  {
277  $this->assertEquals('0', $portlet->collapsed);
278  $portletPostData['LeadDetailsAndRelationsView_' . $portlet->id] = array(
279  'collapsed' => 'true',
280  'column' => 0,
281  'id' => 'LeadDetailsAndRelationsView_' . $portlet->id,
282  'position' => $portletCount,
283  );
284  $portletCount++;
285  }
286  }
287  //There should have been a total of 5 portlets.
288  $this->assertEquals(6, $portletCount);
289  $this->resetGetArray();
290  $this->setPostArray(array(
291  'portletLayoutConfiguration' => array(
292  'portlets' => $portletPostData,
293  'uniqueLayoutId' => 'LeadDetailsAndRelationsView',
294  )
295  ));
296  $this->runControllerWithNoExceptionsAndGetContent('home/defaultPortlet/saveLayout', true);
297  //Now test that all the portlets are collapsed and moved to the first column.
298  $portlets = Portlet::getByLayoutIdAndUserSortedByColumnIdAndPosition(
299  'LeadDetailsAndRelationsView', $super->id, array());
300  $this->assertEquals (6, count($portlets[1]));
301  $this->assertFalse (array_key_exists(2, $portlets) );
302  foreach ($portlets as $column => $columns)
303  {
304  foreach ($columns as $position => $positionPortlets)
305  {
306  $this->assertEquals('1', $positionPortlets->collapsed);
307  }
308  }
309  //Load Details View again to make sure everything is ok after the layout change.
310  $this->setGetArray(array('id' => $superLeadId4));
311  $this->resetPostArray();
312  $this->runControllerWithNoExceptionsAndGetContent('leads/default/details');
313  }
314 
318  public function testSuperUserDeleteAction()
319  {
320  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
321  $superLeadId4 = self::getModelIdByModelNameAndName('Contact', 'superLead4 superLead4son');
322  //Delete a lead.
323  $this->setGetArray(array('id' => $superLeadId4));
324  $this->resetPostArray();
325  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/delete');
326  $leads = Contact::getAll();
327  $this->assertEquals(11, count($leads));
328  try
329  {
330  Contact::getById($superLeadId4);
331  $this->fail();
332  }
333  catch (NotFoundException $e)
334  {
335  //success
336  }
337  }
338 
342  public function testSuperUserCreateAction()
343  {
344  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
345 
346  //Confirm the starting states exist
347  $this->assertEquals(6, count(ContactState::GetAll()));
348  $startingState = LeadsUtil::getStartingState();
349  //Create a new contact.
350  $this->resetGetArray();
351  $this->setPostArray(array('Contact' => array(
352  'firstName' => 'myNewLead',
353  'lastName' => 'myNewLeadson',
354  'officePhone' => '456765421',
355  'state' => array('id' => $startingState->id)
356  )
357  )
358  );
359  $this->runControllerWithRedirectExceptionAndGetContent('contacts/default/create');
360  $leads = Contact::getByName('myNewLead myNewLeadson');
361  $this->assertEquals(1, count($leads));
362  $this->assertTrue($leads[0]->id > 0);
363  $this->assertTrue($leads[0]->owner == $super);
364  $this->assertTrue($leads[0]->state == $startingState);
365  $this->assertEquals('456765421', $leads[0]->officePhone);
366  $leads = Contact::getAll();
367  $this->assertEquals(12, count($leads));
368  }
369 
373  public function testSuperUserCopyAction()
374  {
375  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
376 
377  $leads = Contact::getByName('myNewLead myNewLeadson');
378  $this->assertCount(1, $leads);
379 
380  $postArray = array(
381  'Contact' => array(
382  'firstName' => 'myNewLead',
383  'lastName' => 'myNewLeadson',
384  'jobTitle' => 'job title',
385  'companyName' => 'Some Company',
386  'department' => 'Some department',
387  'officePhone' => '456765421',
388  'mobilePhone' => '958462315',
389  'officeFax' => '123456789',
390  'primaryEmail' => array(
391  'emailAddress' => 'a@a.com',
392  ),
393  'secondaryEmail' => array(
394  'emailAddress' => 'b@b.com',
395  ),
396  'primaryAddress' => array(
397  'street1' => 'Street1',
398  'street2' => 'Street2',
399  'city' => 'City',
400  'state' => 'State',
401  'postalCode' => '12345',
402  'country' => 'Country',
403  ),
404  'secondaryAddress' => array(
405  'street1' => 'Street1',
406  'street2' => 'Street2',
407  'city' => 'City',
408  'state' => 'State',
409  'postalCode' => '12345',
410  'country' => 'Country',
411  ),
412  'website' => 'http://example.com',
413  'description' => 'some description',
414  )
415  );
416 
417  $this->updateModelValuesFromPostArray($leads[0], $postArray);
418  $this->assertModelHasValuesFromPostArray($leads[0], $postArray);
419 
420  $this->assertTrue($leads[0]->save());
421  $this->assertTrue(
422  $this->checkCopyActionResponseAttributeValuesFromPostArray($leads[0], $postArray, 'Lead', 'leads')
423  );
424 
425  $postArray['Contact']['firstName'] = 'myClonedLead';
426  $postArray['Contact']['lastName'] = 'myClonedLeadson';
427  $postArray['Contact']['state'] = array('id' => LeadsUtil::getStartingState()->id);
428  $this->setGetArray(array('id' => $leads[0]->id));
429  $this->setPostArray($postArray);
430  $this->runControllerWithRedirectExceptionAndGetUrl('leads/default/copy');
431 
432  $leads = Contact::getByName('myClonedLead myClonedLeadson');
433  $this->assertCount(1, $leads);
434  $this->assertTrue($leads[0]->owner->isSame($super));
435 
436  unset($postArray['Contact']['state']);
437  $this->assertModelHasValuesFromPostArray($leads[0], $postArray);
438 
439  $leads = Contact::getAll();
440  $this->assertCount(13, $leads);
441  }
442 
446  public function testSuperUserConvertAction()
447  {
448  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
449 
450  $startingLeadState = LeadsUtil::getStartingState();
451  $startingContactState = ContactsUtil::getStartingState();
452  $leads = Contact::getByName('myNewLead myNewLeadson');
453  $this->assertEquals(1, count($leads));
454  $lead = $leads[0];
455  $this->assertTrue($lead->state == $startingLeadState);
456  //Test just going to the convert page.
457  $this->setGetArray(array('id' => $lead->id));
458  $this->resetPostArray();
459 
460  //Test trying to convert by skipping account creation and by skipping opportunity creation
461  $this->runControllerWithNoExceptionsAndGetContent('leads/default/convert');
462  $this->setGetArray(array('id' => $lead->id));
463  $this->setPostArray(array('AccountSkip' => 'Not Used'));
464  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
465  $this->setGetArray(array('id' => $lead->id));
466  $this->setPostArray(array('OpportunitySkip' => 'Not Used'));
467  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
468  $leadId = $lead->id;
469  $lead->forget();
470  $contact = Contact::getById($leadId);
471  $this->assertTrue($contact->state == $startingContactState);
472 
473  //Test trying to convert by creating a new account and by skipping opportunity creation.
474  $lead5 = LeadTestHelper::createLeadbyNameForOwner('superLead5', $super);
475  $this->assertTrue($lead5->state == $startingLeadState);
476  $this->setGetArray(array('id' => $lead5->id));
477  $this->setPostArray(array('Account' => array('name' => 'someAccountName')));
478  $this->assertEquals(0, Account::getCount());
479  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
480  $this->setGetArray(array('id' => $lead5->id));
481  $this->setPostArray(array('OpportunitySkip' => 'Not Used'));
482  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
483  $this->assertEquals(1, Account::getCount());
484  $lead5Id = $lead5->id;
485  $lead5->forget();
486  $contact5 = Contact::getById($lead5Id);
487  $this->assertTrue($contact5->state == $startingContactState);
488  $this->assertEquals('someAccountName', $contact5->account->name);
489 
490  //Test trying to convert by selecting an existing account and by skipping opportunity creation.
491  $account = AccountTestHelper::createAccountbyNameForOwner('someNewAccount', $super);
492  $lead6 = LeadTestHelper::createLeadbyNameForOwner('superLead6', $super);
493  $this->assertTrue($lead6->state == $startingLeadState);
494  $this->setGetArray(array('id' => $lead6->id));
495  $this->setPostArray(array('AccountSelectForm' => array('accountId' => $account->id,
496  'accountName' => 'someNewAccount')));
497  $this->assertEquals(2, Account::getCount());
498  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
499  $this->setGetArray(array('id' => $lead6->id));
500  $this->setPostArray(array('OpportunitySkip' => 'Not Used'));
501  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
502  $this->assertEquals(2, Account::getCount());
503  $lead6Id = $lead6->id;
504  $lead6->forget();
505  $contact6 = Contact::getById($lead6Id);
506  $this->assertTrue($contact6->state == $startingContactState);
507  $this->assertEquals($account, $contact6->account);
508 
509  //Test trying to convert by skipping account creation and by creating new opportunity
510  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
511  $leadOpp = LeadTestHelper::createLeadbyNameForOwner('superLeadOpp', $super);
512  $this->setGetArray(array('id' => $leadOpp->id));
513  $this->setPostArray(array('AccountSkip' => 'Not Used'));
514  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
515  $this->setGetArray(array('id' => $leadOpp->id));
516  $this->setPostArray(
517  array('Opportunity' =>
518  array(
519  'name' => 'someOpportunityName',
520  'amount' => array('currency' => array('id' => '1'), 'value' => '100'),
521  'closeDate' => '6/19/2014',
522  'stage' => array('value' => 'Negotiating'),
523  'probability' => '50'
524  )
525  )
526  );
527  $this->assertEquals(0, Opportunity::getCount());
528  $this->assertEquals(2, Account::getCount());
529  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
530  $leadId = $leadOpp->id;
531  $leadOpp->forget();
532  $contact = Contact::getById($leadId);
533  $this->assertTrue($contact->state == $startingContactState);
534  $this->assertEquals(1, Opportunity::getCount());
535  $this->assertEquals(2, Account::getCount());
536  }
537 
538  public function testAccessingContactNotLeadWillRedirectToContacts()
539  {
540  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
541  $contact = ContactTestHelper::createContactbyNameForOwner('ContactNotLead', $super);
542  $this->setGetArray(array('id' => $contact->id));
543  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/edit',
544  Yii::app()->createUrl('contacts/default/edit', array('id' => $contact->id)), true);
545  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/details',
546  Yii::app()->createUrl('contacts/default/details', array('id' => $contact->id)), true);
547  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/delete',
548  Yii::app()->createUrl('contacts/default/delete', array('id' => $contact->id)), true);
549  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert',
550  Yii::app()->createUrl('contacts/default/details', array('id' => $contact->id)), true);
551  }
552 
557  {
558  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
559  $leads = Contact::getAll();
560  $this->assertEquals(17, count($leads));
561  $superLeadId = self::getModelIdByModelNameAndName('Contact', 'superLead');
562  $superLeadId2 = self::getModelIdByModelNameAndName('Contact', 'superLead2 superLead2son');
563  $superLeadId3 = self::getModelIdByModelNameAndName('Contact', 'superLead3 superLead3son');
564  $superLeadId4 = self::getModelIdByModelNameAndName('Contact', 'myNewLead myNewLeadson');
565  $superLeadId5 = self::getModelIdByModelNameAndName('Contact', 'superLead5 superLead5son');
566  $superLeadId6 = self::getModelIdByModelNameAndName('Contact', 'superLead6 superLead6son');
567  $superLeadId7 = self::getModelIdByModelNameAndName('Contact', 'superLead7 superLead7son');
568  $superLeadId8 = self::getModelIdByModelNameAndName('Contact', 'superLead8 superLead8son');
569  $superLeadId9 = self::getModelIdByModelNameAndName('Contact', 'superLead9 superLead9son');
570  $superLeadId10 = self::getModelIdByModelNameAndName('Contact', 'superLead10 superLead10son');
571  $superLeadId11 = self::getModelIdByModelNameAndName('Contact', 'superLead11 superLead11son');
572  $superLeadId12 = self::getModelIdByModelNameAndName('Contact', 'superLead12 superLead12son');
573  $superLeadId13 = self::getModelIdByModelNameAndName('Contact', 'myClonedLead myClonedLeadson');
574  //Load Model MassDelete Views.
575 
576  //MassDelete view for single selected ids
577  $this->setGetArray(array('selectedIds' => '5,6,7,8,9', 'selectAll' => '', )); // Not Coding Standard
578  $this->resetPostArray();
579  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massDelete');
580  $this->assertContains('<strong>5</strong>&#160;Leads selected for removal', $content);
581 
582  //MassDelete view for all result selected ids
583  $this->setGetArray(array('selectAll' => '1'));
584  $this->resetPostArray();
585  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massDelete');
586  $this->assertContains('<strong>12</strong>&#160;Leads selected for removal', $content);
587  //MassDelete for selected Record Count
588  $leads = Contact::getAll();
589  $this->assertEquals(17, count($leads));
590 
591  //MassDelete for selected ids for paged scenario
592  $lead1 = Contact::getById($superLeadId);
593  $lead2 = Contact::getById($superLeadId2);
594  $lead3 = Contact::getById($superLeadId3);
595  $lead4 = Contact::getById($superLeadId4);
596  $lead5 = Contact::getById($superLeadId5);
597  $lead6 = Contact::getById($superLeadId6);
598 
599  $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
600  $this->assertEquals(5, $pageSize);
601  //MassDelete for selected ids for page 1
602  $this->setGetArray(array(
603  'selectedIds' => $superLeadId . ',' . $superLeadId2 . ',' . // Not Coding Standard
604  $superLeadId3 . ',' . $superLeadId4 . ',' . // Not Coding Standard
605  $superLeadId5 . ',' . $superLeadId6, // Not Coding Standard
606  'selectAll' => '',
607  'massDelete' => '',
608  'Contact_page' => 1));
609  $this->setPostArray(array('selectedRecordCount' => 6));
610  $this->runControllerWithExitExceptionAndGetContent('leads/default/massDelete');
611 
612  //MassDelete for selected Record Count
613  $leads = Contact::getAll();
614  $this->assertEquals(12, count($leads));
615 
616  //MassDelete for selected ids for page 2
617  $this->setGetArray(array(
618  'selectedIds' => $superLeadId . ',' . $superLeadId2 . ',' . // Not Coding Standard
619  $superLeadId3 . ',' . $superLeadId4 . ',' . // Not Coding Standard
620  $superLeadId5 . ',' . $superLeadId6 . ',' . // Not Coding Standard
621  $superLeadId13, // Not Coding Standard
622  'selectAll' => '',
623  'massDelete' => '',
624  'Contact_page' => 2));
625  $this->setPostArray(array('selectedRecordCount' => 7));
626  $this->runControllerWithNoExceptionsAndGetContent('leads/default/massDeleteProgress');
627 
628  //MassDelete for selected Record Count
629  $leads = Contact::getAll();
630  $this->assertEquals(10, count($leads));
631  }
632 
637  {
638  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
639 
640  //MassDelete for selected Record Count
641  $leads = Contact::getAll();
642  $this->assertEquals(10, count($leads));
643 
644  //save Model MassDelete for entire search result
645  $this->setGetArray(array(
646  'selectAll' => '1', // Not Coding Standard
647  'Contact_page' => 1));
648  $this->setPostArray(array('selectedRecordCount' => 6));
649  //Run Mass Delete using progress save for page1.
650  $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
651  $this->assertEquals(5, $pageSize);
652  $this->runControllerWithExitExceptionAndGetContent('leads/default/massDelete');
653 
654  //check for previous mass delete progress
655  $leads = Contact::getAll();
656  $this->assertEquals(5, count($leads));
657 
658  $this->setGetArray(array(
659  'selectAll' => '1', // Not Coding Standard
660  'Contact_page' => 2));
661  $this->setPostArray(array('selectedRecordCount' => 6));
662  //Run Mass Delete using progress save for page2.
663  $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
664  $this->assertEquals(5, $pageSize);
665  $this->runControllerWithNoExceptionsAndGetContent('leads/default/massDeleteProgress');
666 
667  //calculating lead's count
668  $leads = Contact::getAll();
669  /* ContactNotLead, superLead5, superLead6 was converted to a contact.
670  * so this leads are not removed
671  */
672  $this->assertContains('ContactNotLead', serialize($leads));
673  $this->assertContains('superLead5', serialize($leads));
674  $this->assertContains('superLead6', serialize($leads));
675  $this->assertEquals(4, count($leads));
676  }
677 
678  public function testSuperUserSearchForDuplicateModelsAction()
679  {
680  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
681  $this->setGetArray(array('attribute' => 'lastName',
682  'value' => 'fakeValue',
683  ));
684  $this->runControllerWithNoExceptionsAndGetContent('leads/default/searchForDuplicateModels', true);
685 
686  $lead = LeadTestHelper::createLeadbyNameForOwner('test', $super);
687  TaskTestHelper::createTaskWithOwnerAndRelatedItem('task for test', $super, $lead);
688 
689  //Test search by lastName
690  $this->setGetArray(array('attribute' => 'lastName',
691  'value' => 'testson',
692  ));
693  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/searchForDuplicateModels');
694  $object = json_decode($content);
695  $this->assertEquals ('There is 1 possible match. <span class="underline">Click here</span> to view.', $object->message);
696  $this->assertContains('CreateModelsToMergeListAndChartView', $object->content);
697  //The dupe lead has one task
698  $this->assertTag(array(
699  'tag' => 'span',
700  'attributes' => array('class' => 'total-tasks'),
701  'descendant' => array(
702  'tag' => 'strong',
703  'content' => '1',
704  )
705  ),
706  $object->content);
707 
708  //Test search by phone
709  $lead->mobilePhone = '123456789';
710  $this->assertTrue($lead->save());
711  $this->setGetArray(array('attribute' => 'officePhone',
712  'value' => '123456789',
713  ));
714  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/searchForDuplicateModels');
715  $object = json_decode($content);
716  $this->assertEquals ('There is 1 possible match. <span class="underline">Click here</span> to view.', $object->message);
717  $this->assertContains('CreateModelsToMergeListAndChartView', $object->content);
718  //Test search by email
719  $lead->secondaryEmail->emailAddress = 'a@a.a';
720  $this->assertTrue($lead->save());
721  $this->setGetArray(array('attribute' => 'primaryEmail',
722  'value' => 'a@a.a',
723  ));
724  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/searchForDuplicateModels');
725  $object = json_decode($content);
726  $this->assertEquals ('There is 1 possible match. <span class="underline">Click here</span> to view.', $object->message);
727  $this->assertContains('CreateModelsToMergeListAndChartView', $object->content);
728  }
729 
730  public function testSuperUserConvertActionWithTagCloud()
731  {
732  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
734  DesignerTestHelper::createTagCloudAttribute('tagcloud', false, 'Account');
735  $this->setGetArray(array('moduleClassName' => 'AccountsModule',
736  'viewClassName' => 'AccountConvertToView'));
737  $layout = array(
738  'panels' => array(
739  array(
740  'title' => 'Panel Title',
741  'panelDetailViewOnly' => 1,
742  'rows' => array(
743  array('cells' =>
744  array(
745  array(
746  'element' => 'name',
747  ),
748  )
749  ),
750  array('cells' =>
751  array(
752  array(
753  'element' => 'tagcloudCstm',
754  ),
755  )
756  ),
757  ),
758  ),
759  ),
760  );
761  $this->setPostArray(array('save' => 'Save', 'layout' => $layout));
762  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
763  $this->assertContains('Layout saved successfully', $content);
764 
765  $lead = LeadTestHelper::createLeadbyNameForOwner('convertwithtagcloud', $super);
766  $this->setGetArray(array('id' => $lead->id));
767  $this->setPostArray(
768  array(
769  'Account' => array(
770  'name' => 'mynewaccountfromleadtagcloudconvert',
771  'tagcloudCstm' => array('values' => 'English,French') // Not Coding Standard
772  )
773  )
774  );
775  $this->assertEquals(0, Account::getCount());
776  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
777  $this->setGetArray(array('id' => $lead->id));
778  $this->setPostArray(array('OpportunitySkip' => 'Not Used'));
779  $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convertFinal');
780  $this->assertEquals(1, Account::getCount());
781  $accounts = Account::getAll();
782  $this->assertEquals('English, French', strval($accounts[0]->tagcloudCstm));
783  }
784 
785  public function testInlineCreateCommentFromAjax()
786  {
787  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
788  $lead = LeadTestHelper::createLeadbyNameForOwner('testLead22', $super);
789 
790  $this->setGetArray(array('id' => $lead->id, 'uniquePageId' => 'CommentInlineEditForModelView'));
791  $this->runControllerWithNoExceptionsAndGetContent('leads/default/inlineCreateCommentFromAjax');
792  }
793 
798  {
799  //Login with super and check subscribe unsubscribe from modal detail view when super
800  //is not owner or requested by user
801  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
802  $mike = UserTestHelper::createBasicUser('mike');
803  $lead = LeadTestHelper::createLeadbyNameForOwner('leadNew', $mike);
804  $this->assertEquals(1, $lead->notificationSubscribers->count());
805 
806  $this->setGetArray(array('id' => $lead->id));
808  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/addSubscriber', false);
809  $this->assertContains('gravatar', $content);
810  $this->assertContains('users/default/details', $content);
811  $this->assertContains($super->getFullName(), $content);
812  $this->assertEquals(2, $lead->notificationSubscribers->count());
813 
814  $this->setGetArray(array('id' => $lead->id));
815  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/removeSubscriber', false);
816  $this->assertNotContains($super->getFullName(), $content);
817  $this->assertEquals(1, $lead->notificationSubscribers->count());
818  $lead->owner = $super;
819  $this->assertTrue($lead->save());
820  $this->assertEquals(2, $lead->notificationSubscribers->count());
821 
822  //Super user is owner so even if it is removed, it would be restored
823  $this->setGetArray(array('id' => $lead->id));
824  $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/removeSubscriber', false);
825  $this->assertContains($super->getFullName(), $content);
826  $this->assertEquals(2, $lead->notificationSubscribers->count());
827  }
828  }
829 ?>
static getByLayoutIdAndUser($layoutId, $user)
Definition: Dashboard.php:46
static getByUsername($username)
Definition: User.php:49
runControllerWithRedirectExceptionAndGetContent($route, $compareUrl=null, $compareUrlContains=false)
static getStartingState()
updateModelValuesFromPostArray($model, $postArray)
static deleteAll()
static getCount(RedBeanModelJoinTablesQueryAdapter $joinTablesAdapter=null, $where=null, $modelClassName=null, $selectDistinct=false)
checkCopyActionResponseAttributeValuesFromPostArray($model, $postArray, $linkClass=null, $controllerId=null)
static doNotificationSubscribersContainPerson(OwnedSecurableItem $model, Item $item)
static getById($id, $modelClassName=null)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
assertModelHasValuesFromPostArray($model, $postArray)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null)
static getStartingState()
Definition: LeadsUtil.php:152
Generated on Sun Nov 29 2020 07:10:26
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.