Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ContactsDesignerSuperUserWalkthroughTest.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 
47  {
48  public static $activateDefaultLanguages = true;
49 
50  public static function setUpBeforeClass()
51  {
52  parent::setUpBeforeClass();
53  SecurityTestHelper::createSuperAdmin();
54  $super = User::getByUsername('super');
55  Yii::app()->user->userModel = $super;
56  Currency::makeBaseCurrency();
57  //Create a contact for testing.
58  $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
59  ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
60  }
61 
62  public function testSuperUserContactDefaultControllerActions()
63  {
64  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
65 
66  //Default Controller actions requiring some sort of parameter via POST or GET
67  //Load Conatct Modules Menu.
68  $this->resetPostArray();
69  $this->setGetArray(array('moduleClassName' => 'ContactsModule'));
70  $this->runControllerWithNoExceptionsAndGetContent('designer/default/modulesMenu');
71 
72  //Load AttributesList for Contacts module.
73  $this->setGetArray(array('moduleClassName' => 'ContactsModule'));
74  $this->runControllerWithNoExceptionsAndGetContent('designer/default/attributesList');
75 
76  //Load ModuleLayoutsList for Conatct module.
77  $this->setGetArray(array('moduleClassName' => 'ContactsModule'));
78  $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleLayoutsList');
79 
80  //Load ModuleEdit view for each applicable module.
81  $this->setGetArray(array('moduleClassName' => 'ContactsModule'));
82  $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleEdit');
83 
84  //Now validate save with failed validation.
85  $this->setGetArray(array('moduleClassName' => 'ContactsModule'));
86  $this->setPostArray(array('ajax' => 'edit-form',
87  'ContactsModuleForm' => $this->createModuleEditBadValidationPostData()));
88  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/moduleEdit');
89  $this->assertTrue(strlen($content) > 50); //approximate, but should definetely be larger than 50.
90 
91  //Now validate save with successful validation.
92  $this->setGetArray(array('moduleClassName' => 'ContactsModule'));
93  $this->setPostArray(array('ajax' => 'edit-form',
94  'ContactsModuleForm' => $this->createModuleEditGoodValidationPostData('con new name')));
95  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/moduleEdit');
96  $this->assertEquals('[]', $content);
97 
98  //Now save successfully.
99  $value = ContactsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted();
100  $this->assertTrue($value);
101  $value = ContactsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated();
102  $this->assertTrue($value);
103  $value = ContactsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived();
104  $this->assertTrue($value);
105  $value = ContactsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast();
106  $this->assertTrue($value);
107  $postDataForForm = $this->createModuleEditGoodValidationPostData('con new name');
108  $postDataForForm['updateLatestActivityDateTimeWhenATaskIsCompleted'] = '';
109  $postDataForForm['updateLatestActivityDateTimeWhenANoteIsCreated'] = '';
110  $postDataForForm['updateLatestActivityDateTimeWhenAnEmailIsSentOrArchived'] = '';
111  $postDataForForm['updateLatestActivityDateTimeWhenAMeetingIsInThePast'] = '';
112  $this->setGetArray(array('moduleClassName' => 'ContactsModule'));
113  $this->setPostArray(array('save' => 'Save', 'ContactsModuleForm' => $postDataForForm));
114  $this->runControllerWithRedirectExceptionAndGetContent('designer/default/moduleEdit');
115 
116  //Now confirm everything did in fact save correctly.
117  $this->assertEquals('Con New Name', ContactsModule::getModuleLabelByTypeAndLanguage('Singular'));
118  $this->assertEquals('Con New Names', ContactsModule::getModuleLabelByTypeAndLanguage('Plural'));
119  $this->assertEquals('con new name', ContactsModule::getModuleLabelByTypeAndLanguage('SingularLowerCase'));
120  $this->assertEquals('con new names', ContactsModule::getModuleLabelByTypeAndLanguage('PluralLowerCase'));
121  $value = ContactsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted();
122  $this->assertFalse($value);
123  $value = ContactsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated();
124  $this->assertFalse($value);
125  $value = ContactsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived();
126  $this->assertFalse($value);
127  $value = ContactsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast();
128  $this->assertFalse($value);
129 
130  //Load LayoutEdit for each applicable module and applicable layout
131  $this->resetPostArray();
132  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
133  'viewClassName' => 'ContactEditAndDetailsView'));
134  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
135  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
136  'viewClassName' => 'ContactsListView'));
137  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
138  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
139  'viewClassName' => 'ContactsModalListView'));
140  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
141  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
142  'viewClassName' => 'ContactsModalSearchView'));
143  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
144  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
145  'viewClassName' => 'ContactsMassEditView'));
146  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
147  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
148  'viewClassName' => 'ContactsRelatedListView'));
149  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
150  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
151  'viewClassName' => 'ContactsSearchView'));
152  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
153  }
154 
159  {
160  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
161 
162  //Test create field list.
163  $this->setGetArray(array('moduleClassName' => 'ContactsModule'));
164 
165  //View creation screen, then create custom field for each custom field type.
166  $this->createCheckBoxCustomFieldByModule ('ContactsModule', 'checkbox');
167  $this->createCurrencyValueCustomFieldByModule ('ContactsModule', 'currency');
168  $this->createDateCustomFieldByModule ('ContactsModule', 'date');
169  $this->createDateTimeCustomFieldByModule ('ContactsModule', 'datetime');
170  $this->createDecimalCustomFieldByModule ('ContactsModule', 'decimal');
171  $this->createDropDownCustomFieldByModule ('ContactsModule', 'picklist');
172  $this->createDependentDropDownCustomFieldByModule ('ContactsModule', 'countrylist');
173  $this->createDependentDropDownCustomFieldByModule ('ContactsModule', 'statelist');
174  $this->createDependentDropDownCustomFieldByModule ('ContactsModule', 'citylist');
175  $this->createIntegerCustomFieldByModule ('ContactsModule', 'integer');
176  $this->createMultiSelectDropDownCustomFieldByModule ('ContactsModule', 'multiselect');
177  $this->createTagCloudCustomFieldByModule ('ContactsModule', 'tagcloud');
178  $this->createCalculatedNumberCustomFieldByModule ('ContactsModule', 'calcnumber');
179  $this->createDropDownDependencyCustomFieldByModule ('ContactsModule', 'dropdowndep');
180  $this->createPhoneCustomFieldByModule ('ContactsModule', 'phone');
181  $this->createRadioDropDownCustomFieldByModule ('ContactsModule', 'radio');
182  $this->createTextCustomFieldByModule ('ContactsModule', 'text');
183  $this->createTextAreaCustomFieldByModule ('ContactsModule', 'textarea');
184  $this->createUrlCustomFieldByModule ('ContactsModule', 'url');
185  }
186 
191  {
192  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
193 
194  //Add custom fields to ContactEditAndDetailsView.
195  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
196  'viewClassName' => 'ContactEditAndDetailsView'));
198  $this->setPostArray(array('save' => 'Save', 'layout' => $layout,
199  'LayoutPanelsTypeForm' => array('type' => FormLayout::PANELS_DISPLAY_TYPE_ALL)));
200  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
201  $this->assertContains('Layout saved successfully', $content);
202 
203  //Add all fields to ContactsSearchView.
204  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
205  'viewClassName' => 'ContactsSearchView'));
207  $this->setPostArray(array('save' => 'Save', 'layout' => $layout));
208  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
209  $this->assertContains('Layout saved successfully', $content);
210 
211  //Add all fields to ContactsListView.
212  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
213  'viewClassName' => 'ContactsListView'));
215  $this->setPostArray(array('save' => 'Save', 'layout' => $layout));
216  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
217  $this->assertContains('Layout saved successfully', $content);
218 
219  //Add all fields to ContactsRelatedListView.
220  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
221  'viewClassName' => 'ContactsRelatedListView'));
223  $this->setPostArray(array('save' => 'Save', 'layout' => $layout));
224  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
225  $this->assertContains('Layout saved successfully', $content);
226 
227  //Add all fields to ContactsMassEditView.
228  $this->setGetArray(array('moduleClassName' => 'ContactsModule',
229  'viewClassName' => 'ContactsMassEditView'));
231  $this->setPostArray(array('save' => 'Save', 'layout' => $layout));
232  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
233  $this->assertContains('Layout saved successfully', $content);
234  }
235 
240  {
241  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
242  $superAccountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
243  $superContactId = self::getModelIdByModelNameAndName ('Contact', 'superContact superContactson');
244  //Load create, edit, and details views.
245  $this->runControllerWithNoExceptionsAndGetContent('contacts/default/create');
246  $this->setGetArray(array('id' => $superContactId));
247  $this->runControllerWithNoExceptionsAndGetContent('contacts/default/edit');
248  $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
249  $this->runControllerWithNoExceptionsAndGetContent('contacts/default/list');
250  $this->setGetArray(array(
251  'modalTransferInformation' => array('sourceIdFieldId' => 'x', 'sourceNameFieldId' => 'y', 'modalId' => 'z')
252  ));
253  $this->resetPostArray();
254  $this->runControllerWithNoExceptionsAndGetContent('contacts/default/modalList');
255  $this->setGetArray(array('id' => $superAccountId));
256  $this->resetPostArray();
257  $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
258  $this->setGetArray(array('selectAll' => '1'));
259  $this->resetPostArray();
260  $this->runControllerWithNoExceptionsAndGetContent('contacts/default/massEdit');
261  }
262 
267  {
268  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
269 
270  //test existing ContactState changes to labels.
271  $extraPostData = array( 'startingStateOrder' => '4',
272  'isAudited' => '1',
273  'isRequired' => '1',
274  'contactStatesData' => array(
275  'New', 'In ProgressD', 'RecycledC', 'QualifiedA', 'CustomerF', 'YRE'
276  ),
277  'contactStatesDataExistingValues' => array(
278  'New', 'In Progress', 'Recycled', 'Qualified', 'Customer'
279  )
280  );
281  $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState',
282  $extraPostData, 'state');
283  $compareData = array(
284  'New',
285  'In ProgressD',
286  'RecycledC',
287  'QualifiedA',
288  'CustomerF',
289  'YRE'
290  );
291  $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder());
292 
293  //todo: test that the changed labels, updated the existing data if any existed.
294 
295  //Removing ContactStates items
296  $extraPostData = array( 'startingStateOrder' => '2',
297  'isAudited' => '1',
298  'isRequired' => '1',
299  'contactStatesData' => array(
300  'New', 'RecycledC', 'QualifiedA'
301  ));
302  $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState',
303  $extraPostData, 'state');
304  $compareData = array(
305  'New',
306  'RecycledC',
307  'QualifiedA',
308  );
309  $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder());
310 
311  //Adding ContactStates items
312  $extraPostData = array( 'startingStateOrder' => '2',
313  'isAudited' => '1',
314  'isRequired' => '1',
315  'contactStatesData' => array(
316  'New', 'RecycledC', 'QualifiedA', 'NewItem', 'NewItem2'
317  ));
318  $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState',
319  $extraPostData, 'state');
320  $compareData = array(
321  'New',
322  'RecycledC',
323  'QualifiedA',
324  'NewItem',
325  'NewItem2'
326  );
327  $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder());
328 
329  //Changing order of ContactStates items
330  $extraPostData = array( 'startingStateOrder' => '2',
331  'isAudited' => '1',
332  'isRequired' => '1',
333  'contactStatesData' => array(
334  'New', 'NewItem2', 'RecycledC', 'QualifiedA', 'NewItem'
335  ));
336  $this->createCustomAttributeWalkthroughSequence('ContactsModule', 'state', 'ContactState',
337  $extraPostData, 'state');
338  $compareData = array(
339  'New',
340  'NewItem2',
341  'RecycledC',
342  'QualifiedA',
343  'NewItem',
344  );
345  $this->assertEquals($compareData, ContactsUtil::getContactStateDataKeyedByOrder());
346 
347  //test trying to save 2 ContactStates with the same name (QualifiedA is twice)
348  $extraPostData = array( 'startingStateOrder' => '2',
349  'isAudited' => '1',
350  'isRequired' => '1',
351  'contactStatesData' => array(
352  'New', 'NewItem2', 'QualifiedA', 'QualifiedA', 'NewItem'
353  ));
354  $this->setGetArray(array( 'moduleClassName' => 'ContactsModule',
355  'attributeTypeName' => 'ContactState',
356  'attributeName' => 'state'));
357  $this->setPostArray(array( 'ajax' => 'edit-form',
358  'ContactStateAttributeForm' => array_merge(array(
359  'attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'),
360  'attributeName' => 'state',
361  ), $extraPostData)));
362  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit');
363  $this->assertTrue(strlen($content) > 50); //approximate, but should definetely be larger than 50.
364 
365  //test trying to save 0 ContactStates
366  $extraPostData = array( 'startingStateOrder' => '2',
367  'isAudited' => '1',
368  'isRequired' => '1',
369  'contactStatesData' => array());
370  $this->setPostArray(array( 'ajax' => 'edit-form',
371  'ContactStateAttributeForm' => array_merge(array(
372  'attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'),
373  'attributeName' => 'state',
374  ), $extraPostData)));
375  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit');
376  $this->assertTrue(strlen($content) > 50); //approximate, but should definetely be larger than 50.
377 
378  //test trying to save contact states that are shorter than the minimum length.
379  $extraPostData = array( 'startingStateOrder' => '2',
380  'isAudited' => '1',
381  'isRequired' => '1',
382  'contactStatesData' => array('', ' NB', 'NC'));
383  $this->setPostArray(array( 'ajax' => 'edit-form',
384  'ContactStateAttributeForm' => array_merge(array(
385  'attributeLabels' => $this->createAttributeLabelGoodValidationPostData('state'),
386  'attributeName' => 'state',
387  ), $extraPostData)));
388  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/attributeEdit');
389  $this->assertTrue(strlen($content) > 50); //approximate, but should definetely be larger than 50.
390  }
391 
396  {
397  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
398 
399  //Retrieve the super account id and the super user id.
400  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
401  $superUserId = $super->id;
402 
403  //Set the date and datetime variable values here.
404  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
405  $dateAssert = date('Y-m-d');
406  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
407  $datetimeAssert = date('Y-m-d H:i:')."00";
408  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
409 
410  //Retrieve the Contact State (Status) Id based on the name.
411  $contactState = ContactState::getByName('QualifiedA');
412  $contactStateId = $contactState[0]->id;
413 
414  //Create a new contact based on the custom fields.
415  $this->resetGetArray();
416  $this->setPostArray(array('Contact' => array(
417  'title' => array('value' => 'Mr.'),
418  'firstName' => 'Sarah',
419  'lastName' => 'Williams',
420  'state' => array('id' => $contactStateId),
421  'jobTitle' => 'Sales Director',
422  'account' => array('id' => $accountId),
423  'department' => 'Sales',
424  'officePhone' => '739-741-3005',
425  'source' => array('value' => 'Self-Generated'),
426  'mobilePhone' => '285-301-8232',
427  'officeFax' => '255-455-1914',
428  'primaryEmail' => array('emailAddress' => 'info@myNewContact.com',
429  'optOut' => '1',
430  'isInvalid' => '0'),
431  'secondaryEmail' => array('emailAddress' => '',
432  'optOut' => '0',
433  'isInvalid' => '0'),
434  'primaryAddress' => array('street1' => '6466 South Madison Creek',
435  'street2' => '',
436  'city' => 'Chicago',
437  'state' => 'IL',
438  'postalCode' => '60652',
439  'country' => 'USA'),
440  'secondaryAddress' => array('street1' => '26217 West Third Lane',
441  'street2' => '',
442  'city' => 'New York',
443  'state' => 'NY',
444  'postalCode' => '10169',
445  'country' => 'USA'),
446  'owner' => array('id' => $superUserId),
447  'explicitReadWriteModelPermissions' => array('type' => null),
448  'description' => 'This is a Description',
449  'checkboxCstm' => '1',
450  'currencyCstm' => array('value' => 45,
451  'currency' => array(
452  'id' => $baseCurrency->id)),
453  'dateCstm' => $date,
454  'datetimeCstm' => $datetime,
455  'decimalCstm' => '123',
456  'picklistCstm' => array('value' => 'a'),
457  'multiselectCstm' => array('values' => array('ff', 'rr')),
458  'tagcloudCstm' => array('values' => array('writing', 'gardening')),
459  'countrylistCstm' => array('value' => 'bbbb'),
460  'statelistCstm' => array('value' => 'bbb1'),
461  'citylistCstm' => array('value' => 'bb1'),
462  'integerCstm' => '12',
463  'phoneCstm' => '259-784-2169',
464  'radioCstm' => array('value' => 'd'),
465  'textCstm' => 'This is a test Text',
466  'textareaCstm' => 'This is a test TextArea',
467  'urlCstm' => 'http://wwww.abc.com')));
468  $this->runControllerWithRedirectExceptionAndGetUrl('contacts/default/create');
469 
470  //Check the details if they are saved properly for the custom fields.
471  $contactId = self::getModelIdByModelNameAndName ('Contact', 'Sarah Williams');
472  $contact = Contact::getById($contactId);
473  //Retrieve the permission of the contact.
474  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
475  makeBySecurableItem($contact);
476  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
477  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
478 
479  $this->assertEquals($contact->title->value , 'Mr.');
480  $this->assertEquals($contact->firstName , 'Sarah');
481  $this->assertEquals($contact->lastName , 'Williams');
482  $this->assertEquals($contact->state->id , $contactStateId);
483  $this->assertEquals($contact->jobTitle , 'Sales Director');
484  $this->assertEquals($contact->account->id , $accountId);
485  $this->assertEquals($contact->department , 'Sales');
486  $this->assertEquals($contact->officePhone , '739-741-3005');
487  $this->assertEquals($contact->source->value , 'Self-Generated');
488  $this->assertEquals($contact->mobilePhone , '285-301-8232');
489  $this->assertEquals($contact->officeFax , '255-455-1914');
490  $this->assertEquals($contact->primaryEmail->emailAddress , 'info@myNewContact.com');
491  $this->assertEquals($contact->primaryEmail->optOut , '1');
492  $this->assertEquals($contact->primaryEmail->isInvalid , '0');
493  $this->assertEquals($contact->secondaryEmail->emailAddress , '');
494  $this->assertEquals($contact->secondaryEmail->optOut , '0');
495  $this->assertEquals($contact->secondaryEmail->isInvalid , '0');
496  $this->assertEquals($contact->primaryAddress->street1 , '6466 South Madison Creek');
497  $this->assertEquals($contact->primaryAddress->street2 , '');
498  $this->assertEquals($contact->primaryAddress->city , 'Chicago');
499  $this->assertEquals($contact->primaryAddress->state , 'IL');
500  $this->assertEquals($contact->primaryAddress->postalCode , '60652');
501  $this->assertEquals($contact->primaryAddress->country , 'USA');
502  $this->assertEquals($contact->secondaryAddress->street1 , '26217 West Third Lane');
503  $this->assertEquals($contact->secondaryAddress->street2 , '');
504  $this->assertEquals($contact->secondaryAddress->city , 'New York');
505  $this->assertEquals($contact->secondaryAddress->state , 'NY');
506  $this->assertEquals($contact->secondaryAddress->postalCode , '10169');
507  $this->assertEquals($contact->secondaryAddress->country , 'USA');
508  $this->assertEquals($contact->owner->id , $superUserId);
509  $this->assertEquals(0 , count($readWritePermitables));
510  $this->assertEquals(0 , count($readOnlyPermitables));
511  $this->assertEquals($contact->description , 'This is a Description');
512  $this->assertEquals($contact->checkboxCstm , '1');
513  $this->assertEquals($contact->currencyCstm->value , 45);
514  $this->assertEquals($contact->currencyCstm->currency->id , $baseCurrency->id);
515  $this->assertEquals($contact->dateCstm , $dateAssert);
516  $this->assertEquals($contact->datetimeCstm , $datetimeAssert);
517  $this->assertEquals($contact->decimalCstm , '123');
518  $this->assertEquals($contact->picklistCstm->value , 'a');
519  $this->assertEquals($contact->integerCstm , 12);
520  $this->assertEquals($contact->phoneCstm , '259-784-2169');
521  $this->assertEquals($contact->radioCstm->value , 'd');
522  $this->assertEquals($contact->textCstm , 'This is a test Text');
523  $this->assertEquals($contact->textareaCstm , 'This is a test TextArea');
524  $this->assertEquals($contact->urlCstm , 'http://wwww.abc.com');
525  $this->assertEquals($contact->countrylistCstm->value , 'bbbb');
526  $this->assertEquals($contact->statelistCstm->value , 'bbb1');
527  $this->assertEquals($contact->citylistCstm->value , 'bb1');
528  $this->assertContains('ff' , $contact->multiselectCstm->values);
529  $this->assertContains('rr' , $contact->multiselectCstm->values);
530  $this->assertContains('writing' , $contact->tagcloudCstm->values);
531  $this->assertContains('gardening' , $contact->tagcloudCstm->values);
533  getByNameAndModelClassName('calcnumber', 'Contact');
534  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $contact);
535  $this->assertEquals(135 , $testCalculatedValue);
536  }
537 
542  {
543  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
544 
545  //Retrieve the super account id and the super user id.
546  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
547  $superUserId = $super->id;
548 
549  //Retrieve the Contact State (Status) Id based on the name.
550  $contactState = ContactState::getByName('QualifiedA');
551  $contactStateId = $contactState[0]->id;
552 
553  //Search a created contact using the customfields.
554  $this->resetPostArray();
555  $this->setGetArray(array('ContactsSearchForm' => array(
556  'fullName' => 'Sarah Williams',
557  'officePhone' => '739-741-3005',
558  'anyPostalCode' => '10169',
559  'anyCountry' => 'USA',
560  'anyInvalidEmail' => array('value' => '0'),
561  'anyEmail' => 'info@myNewContact.com',
562  'anyOptOutEmail' => array('value' => '1'),
563  'ownedItemsOnly' => '1',
564  'anyStreet' => '26217 West Third Lane',
565  'anyCity' => 'New York',
566  'anyState' => 'NY',
567  'state' => array('id' => $contactStateId),
568  'owner' => array('id' => $superUserId),
569  'firstName' => 'Sarah',
570  'lastName' => 'Williams',
571  'jobTitle' => 'Sales Director',
572  'officeFax' => '255-455-1914',
573  'title' => array('value' => 'Mr.'),
574  'source' => array('value' => 'Self-Generated'),
575  'account' => array('id' => $accountId),
576  'decimalCstm' => '123',
577  'integerCstm' => '12',
578  'phoneCstm' => '259-784-2169',
579  'textCstm' => 'This is a test Text',
580  'textareaCstm' => 'This is a test TextArea',
581  'urlCstm' => 'http://wwww.abc.com',
582  'checkboxCstm' => array('value' => '1'),
583  'currencyCstm' => array('value' => 45),
584  'picklistCstm' => array('value' => 'a'),
585  'multiselectCstm' => array('values' => array('ff', 'rr')),
586  'tagcloudCstm' => array('values' => array('writing', 'gardening')),
587  'countrylistCstm' => array('value' => 'bbbb'),
588  'statelistCstm' => array('value' => 'bbb1'),
589  'citylistCstm' => array('value' => 'bb1'),
590  'radioCstm' => array('value' => 'd'),
591  'dateCstm__Date' => array('type' => 'Today'),
592  'datetimeCstm__DateTime' => array('type' => 'Today')),
593  'ajax' => 'list-view'));
594  $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default');
595 
596  //Check if the contact name exits after the search is performed on the basis of the
597  //custom fields added to the contacts module.
598  //$this->assertContains("Displaying 1-1 of 1 result(s).", $content); //removed until we show the count again in the listview.
599  $this->assertContains("Sarah Williams", $content);
600  }
601 
606  {
607  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
608 
609  //Set the date and datetime variable values here.
610  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
611  $dateAssert = date('Y-m-d');
612  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
613  $datetimeAssert = date('Y-m-d H:i:')."00";
614  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
615  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
616 
617  //Retrieve the super account id and the super user id.
618  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
619  $superUserId = $super->id;
620 
621  //Retrieve the contact id.
622  $contact = Contact::getByName('Sarah Williams');
623  $contactId = $contact[0]->id;
624  $this->assertEquals(2, $contact[0]->tagcloudCstm->values->count());
625 
626  //Retrieve the Contact State (Status) Id based on the name.
627  $contactState = ContactState::getByName('RecycledC');
628  $contactStateId = $contactState[0]->id;
629 
630  //Edit and save the contact.
631  $this->setGetArray(array('id' => $contactId));
632  $this->setPostArray(array('Contact' => array(
633  'title' => array('value' => 'Mrs.'),
634  'firstName' => 'Sarah',
635  'lastName' => 'Williams Edit',
636  'jobTitle' => 'Sales Director Edit',
637  'department' => 'Sales Edit',
638  'officePhone' => '739-742-3005',
639  'source' => array('value' => 'Inbound Call'),
640  'mobilePhone' => '285-300-8232',
641  'officeFax' => '255-454-1914',
642  'state' => array('id' => $contactStateId),
643  'owner' => array('id' => $superUserId),
644  'account' => array('id' => $accountId),
645  'primaryEmail' => array('emailAddress' => 'info@myNewContact.com',
646  'optOut' => '0',
647  'isInvalid' => '0'),
648  'secondaryEmail' => array('emailAddress' => 'info@myNewContactEdit.com',
649  'optOut' => '0',
650  'isInvalid' => '0'),
651  'primaryAddress' => array('street1' => '26378 South Arlington Ave',
652  'street2' => '',
653  'city' => 'San Jose',
654  'state' => 'CA',
655  'postalCode' => '95131',
656  'country' => 'USA'),
657  'secondaryAddress' => array('street1' => '18693 West Spring Center',
658  'street2' => '',
659  'city' => 'Philadelphia',
660  'state' => 'PA',
661  'postalCode' => '19102',
662  'country' => 'USA'),
663  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
664  'description' => 'This is a Edit Description',
665  'checkboxCstm' => '0',
666  'currencyCstm' => array('value' => 40,
667  'currency' => array(
668  'id' => $baseCurrency->id)),
669  'dateCstm' => $date,
670  'datetimeCstm' => $datetime,
671  'decimalCstm' => '12',
672  'picklistCstm' => array('value' => 'b'),
673  'multiselectCstm' => array('values' => array('gg', 'hh')),
674  'tagcloudCstm' => array('values' => array('writing')),
675  'countrylistCstm' => array('value' => 'aaaa'),
676  'statelistCstm' => array('value' => 'aaa1'),
677  'citylistCstm' => array('value' => 'ab1'),
678  'integerCstm' => '11',
679  'phoneCstm' => '259-784-2069',
680  'radioCstm' => array('value' => 'e'),
681  'textCstm' => 'This is a test Edit Text',
682  'textareaCstm' => 'This is a test Edit TextArea',
683  'urlCstm' => 'http://wwww.abc-edit.com'),
684  'save' => 'Save'));
685  $this->runControllerWithRedirectExceptionAndGetUrl('contacts/default/edit');
686 
687  //Check the details if they are saved properly for the custom fields after the edit.
688  $contact = Contact::getById($contactId);
689  //Retrieve the permission of the contact.
690  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
691  makeBySecurableItem($contact);
692  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
693  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
694 
695  $this->assertEquals($contact->title->value , 'Mrs.');
696  $this->assertEquals($contact->firstName , 'Sarah');
697  $this->assertEquals($contact->lastName , 'Williams Edit');
698  $this->assertEquals($contact->state->id , $contactStateId);
699  $this->assertEquals($contact->jobTitle , 'Sales Director Edit');
700  $this->assertEquals($contact->department , 'Sales Edit');
701  $this->assertEquals($contact->officePhone , '739-742-3005');
702  $this->assertEquals($contact->source->value , 'Inbound Call');
703  $this->assertEquals($contact->mobilePhone , '285-300-8232');
704  $this->assertEquals($contact->officeFax , '255-454-1914');
705  $this->assertEquals($contact->primaryEmail->emailAddress , 'info@myNewContact.com');
706  $this->assertEquals($contact->primaryEmail->optOut , '0');
707  $this->assertEquals($contact->primaryEmail->isInvalid , '0');
708  $this->assertEquals($contact->secondaryEmail->emailAddress , 'info@myNewContactEdit.com');
709  $this->assertEquals($contact->secondaryEmail->optOut , '0');
710  $this->assertEquals($contact->secondaryEmail->isInvalid , '0');
711  $this->assertEquals($contact->primaryAddress->street1 , '26378 South Arlington Ave');
712  $this->assertEquals($contact->primaryAddress->street2 , '');
713  $this->assertEquals($contact->primaryAddress->city , 'San Jose');
714  $this->assertEquals($contact->primaryAddress->state , 'CA');
715  $this->assertEquals($contact->primaryAddress->postalCode , '95131');
716  $this->assertEquals($contact->primaryAddress->country , 'USA');
717  $this->assertEquals($contact->secondaryAddress->street1 , '18693 West Spring Center');
718  $this->assertEquals($contact->secondaryAddress->street2 , '');
719  $this->assertEquals($contact->secondaryAddress->city , 'Philadelphia');
720  $this->assertEquals($contact->secondaryAddress->state , 'PA');
721  $this->assertEquals($contact->secondaryAddress->postalCode , '19102');
722  $this->assertEquals($contact->secondaryAddress->country , 'USA');
723  $this->assertEquals(1 , count($readWritePermitables));
724  $this->assertEquals(0 , count($readOnlyPermitables));
725  $this->assertEquals($contact->description , 'This is a Edit Description');
726  $this->assertEquals($contact->checkboxCstm , '0');
727  $this->assertEquals($contact->currencyCstm->value , 40);
728  $this->assertEquals($contact->currencyCstm->currency->id , $baseCurrency->id);
729  $this->assertEquals($contact->dateCstm , $dateAssert);
730  $this->assertEquals($contact->datetimeCstm , $datetimeAssert);
731  $this->assertEquals($contact->decimalCstm , '12');
732  $this->assertEquals($contact->picklistCstm->value , 'b');
733  $this->assertEquals($contact->integerCstm , 11);
734  $this->assertEquals($contact->phoneCstm , '259-784-2069');
735  $this->assertEquals($contact->radioCstm->value , 'e');
736  $this->assertEquals($contact->textCstm , 'This is a test Edit Text');
737  $this->assertEquals($contact->textareaCstm , 'This is a test Edit TextArea');
738  $this->assertEquals($contact->urlCstm , 'http://wwww.abc-edit.com');
739  $this->assertEquals($contact->countrylistCstm->value , 'aaaa');
740  $this->assertEquals($contact->statelistCstm->value , 'aaa1');
741  $this->assertEquals($contact->citylistCstm->value , 'ab1');
742  $this->assertContains('gg' , $contact->multiselectCstm->values);
743  $this->assertContains('hh' , $contact->multiselectCstm->values);
744  $this->assertEquals(1 , $contact->tagcloudCstm->values->count());
746  getByNameAndModelClassName('calcnumber', 'Contact');
747  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $contact);
748  $this->assertEquals(23 , $testCalculatedValue);
749  }
750 
755  {
756  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
757 
758  //Set the date and datetime variable values here.
759  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
760  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
761  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
762  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
763 
764  //Retrieve the super account id and the super user id.
765  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
766  $superUserId = $super->id;
767 
768  //Retrieve the contact id.
769  $contact = Contact::getByName('Sarah Williams Edit');
770  $contactId = $contact[0]->id;
771  $this->assertEquals(1, $contact[0]->tagcloudCstm->values->count());
772 
773  //Retrieve the Contact State (Status) Id based on the name.
774  $contactState = ContactState::getByName('RecycledC');
775  $contactStateId = $contactState[0]->id;
776 
777  //Edit and save the contact.
778  $this->setGetArray(array('id' => $contactId));
779  $this->setPostArray(array('Contact' => array(
780  'title' => array('value' => 'Mrs.'),
781  'firstName' => 'Sarah',
782  'lastName' => 'Williams Edit',
783  'jobTitle' => 'Sales Director Edit',
784  'department' => 'Sales Edit',
785  'officePhone' => '739-742-3005',
786  'source' => array('value' => 'Inbound Call'),
787  'mobilePhone' => '285-300-8232',
788  'officeFax' => '255-454-1914',
789  'state' => array('id' => $contactStateId),
790  'owner' => array('id' => $superUserId),
791  'account' => array('id' => $accountId),
792  'primaryEmail' => array('emailAddress' => 'info@myNewContact.com',
793  'optOut' => '0',
794  'isInvalid' => '0'),
795  'secondaryEmail' => array('emailAddress' => 'info@myNewContactEdit.com',
796  'optOut' => '0',
797  'isInvalid' => '0'),
798  'primaryAddress' => array('street1' => '26378 South Arlington Ave',
799  'street2' => '',
800  'city' => 'San Jose',
801  'state' => 'CA',
802  'postalCode' => '95131',
803  'country' => 'USA'),
804  'secondaryAddress' => array('street1' => '18693 West Spring Center',
805  'street2' => '',
806  'city' => 'Philadelphia',
807  'state' => 'PA',
808  'postalCode' => '19102',
809  'country' => 'USA'),
810  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
811  'description' => 'This is a Edit Description',
812  'checkboxCstm' => '0',
813  'currencyCstm' => array('value' => 40,
814  'currency' => array(
815  'id' => $baseCurrency->id)),
816  'dateCstm' => $date,
817  'datetimeCstm' => $datetime,
818  'decimalCstm' => '12',
819  'picklistCstm' => array('value' => 'b'),
820  'multiselectCstm' => array('values' => array('gg', 'hh')),
821  'tagcloudCstm' => array('values' => array()),
822  'countrylistCstm' => array('value' => 'aaaa'),
823  'statelistCstm' => array('value' => 'aaa1'),
824  'citylistCstm' => array('value' => 'ab1'),
825  'integerCstm' => '11',
826  'phoneCstm' => '259-784-2069',
827  'radioCstm' => array('value' => 'e'),
828  'textCstm' => 'This is a test Edit Text',
829  'textareaCstm' => 'This is a test Edit TextArea',
830  'urlCstm' => 'http://wwww.abc-edit.com'),
831  'save' => 'Save'));
832  $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/edit');
833  $this->assertContains("tagcloud en cannot be blank.", $content);
834  }
835 
840  {
841  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
842 
843  //Set the date and datetime variable values here.
844  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
845  $dateAssert = date('Y-m-d');
846  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
847  $datetimeAssert = date('Y-m-d H:i:')."00";
848  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
849  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
850 
851  //Retrieve the super account id and the super user id.
852  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
853  $superUserId = $super->id;
854 
855  //Retrieve the contact id.
856  $contact = Contact::getByName ('Sarah Williams Edit');
857  $contactId = $contact[0]->id;
858 
859  //Retrieve the Contact State (Status) Id based on the name.
860  $contactState = ContactState::getByName('RecycledC');
861  $contactStateId = $contactState[0]->id;
862 
863  //Edit and save the contact.
864  $this->setGetArray(array('id' => $contactId));
865  $this->setPostArray(array('Contact' => array(
866  'title' => array('value' => 'Mrs.'),
867  'firstName' => 'Sarah',
868  'lastName' => 'Williams Edit',
869  'jobTitle' => 'Sales Director Edit',
870  'department' => 'Sales Edit',
871  'officePhone' => '739-742-3005',
872  'source' => array('value' => 'Inbound Call'),
873  'mobilePhone' => '285-300-8232',
874  'officeFax' => '255-454-1914',
875  'state' => array('id' => $contactStateId),
876  'owner' => array('id' => $superUserId),
877  'account' => array('id' => $accountId),
878  'primaryEmail' => array('emailAddress' => 'info@myNewContact.com',
879  'optOut' => '0',
880  'isInvalid' => '0'),
881  'secondaryEmail' => array('emailAddress' => 'info@myNewContactEdit.com',
882  'optOut' => '0',
883  'isInvalid' => '0'),
884  'primaryAddress' => array('street1' => '26378 South Arlington Ave',
885  'street2' => '',
886  'city' => 'San Jose',
887  'state' => 'CA',
888  'postalCode' => '95131',
889  'country' => 'USA'),
890  'secondaryAddress' => array('street1' => '18693 West Spring Center',
891  'street2' => '',
892  'city' => 'Philadelphia',
893  'state' => 'PA',
894  'postalCode' => '19102',
895  'country' => 'USA'),
896  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
897  'description' => 'This is a Edit Description',
898  'checkboxCstm' => '0',
899  'currencyCstm' => array('value' => 40,
900  'currency' => array(
901  'id' => $baseCurrency->id)),
902  'dateCstm' => $date,
903  'datetimeCstm' => $datetime,
904  'decimalCstm' => '12',
905  'picklistCstm' => array('value' => 'b'),
906  'multiselectCstm' => array('values' => array('gg', 'hh')),
907  'tagcloudCstm' => array('values' => array('reading', 'surfing')),
908  'countrylistCstm' => array('value' => 'aaaa'),
909  'statelistCstm' => array('value' => 'aaa1'),
910  'citylistCstm' => array('value' => 'ab1'),
911  'integerCstm' => '11',
912  'phoneCstm' => '259-784-2069',
913  'radioCstm' => array('value' => 'e'),
914  'textCstm' => 'This is a test Edit Text',
915  'textareaCstm' => 'This is a test Edit TextArea',
916  'urlCstm' => 'http://wwww.abc-edit.com'),
917  'save' => 'Save'));
918  $this->runControllerWithRedirectExceptionAndGetUrl('contacts/default/edit');
919 
920  //Check the details if they are saved properly for the custom fields after the edit.
921  $contact = Contact::getById($contactId);
922  //Retrieve the permission of the contact.
923  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
924  makeBySecurableItem($contact);
925  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
926  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
927 
928  $this->assertEquals($contact->title->value , 'Mrs.');
929  $this->assertEquals($contact->firstName , 'Sarah');
930  $this->assertEquals($contact->lastName , 'Williams Edit');
931  $this->assertEquals($contact->state->id , $contactStateId);
932  $this->assertEquals($contact->jobTitle , 'Sales Director Edit');
933  $this->assertEquals($contact->department , 'Sales Edit');
934  $this->assertEquals($contact->officePhone , '739-742-3005');
935  $this->assertEquals($contact->source->value , 'Inbound Call');
936  $this->assertEquals($contact->mobilePhone , '285-300-8232');
937  $this->assertEquals($contact->officeFax , '255-454-1914');
938  $this->assertEquals($contact->primaryEmail->emailAddress , 'info@myNewContact.com');
939  $this->assertEquals($contact->primaryEmail->optOut , '0');
940  $this->assertEquals($contact->primaryEmail->isInvalid , '0');
941  $this->assertEquals($contact->secondaryEmail->emailAddress , 'info@myNewContactEdit.com');
942  $this->assertEquals($contact->secondaryEmail->optOut , '0');
943  $this->assertEquals($contact->secondaryEmail->isInvalid , '0');
944  $this->assertEquals($contact->primaryAddress->street1 , '26378 South Arlington Ave');
945  $this->assertEquals($contact->primaryAddress->street2 , '');
946  $this->assertEquals($contact->primaryAddress->city , 'San Jose');
947  $this->assertEquals($contact->primaryAddress->state , 'CA');
948  $this->assertEquals($contact->primaryAddress->postalCode , '95131');
949  $this->assertEquals($contact->primaryAddress->country , 'USA');
950  $this->assertEquals($contact->secondaryAddress->street1 , '18693 West Spring Center');
951  $this->assertEquals($contact->secondaryAddress->street2 , '');
952  $this->assertEquals($contact->secondaryAddress->city , 'Philadelphia');
953  $this->assertEquals($contact->secondaryAddress->state , 'PA');
954  $this->assertEquals($contact->secondaryAddress->postalCode , '19102');
955  $this->assertEquals($contact->secondaryAddress->country , 'USA');
956  $this->assertEquals(1 , count($readWritePermitables));
957  $this->assertEquals(0 , count($readOnlyPermitables));
958  $this->assertEquals($contact->description , 'This is a Edit Description');
959  $this->assertEquals($contact->checkboxCstm , '0');
960  $this->assertEquals($contact->currencyCstm->value , 40);
961  $this->assertEquals($contact->currencyCstm->currency->id , $baseCurrency->id);
962  $this->assertEquals($contact->dateCstm , $dateAssert);
963  $this->assertEquals($contact->datetimeCstm , $datetimeAssert);
964  $this->assertEquals($contact->decimalCstm , '12');
965  $this->assertEquals($contact->picklistCstm->value , 'b');
966  $this->assertEquals($contact->integerCstm , 11);
967  $this->assertEquals($contact->phoneCstm , '259-784-2069');
968  $this->assertEquals($contact->radioCstm->value , 'e');
969  $this->assertEquals($contact->textCstm , 'This is a test Edit Text');
970  $this->assertEquals($contact->textareaCstm , 'This is a test Edit TextArea');
971  $this->assertEquals($contact->urlCstm , 'http://wwww.abc-edit.com');
972  $this->assertEquals($contact->countrylistCstm->value , 'aaaa');
973  $this->assertEquals($contact->statelistCstm->value , 'aaa1');
974  $this->assertEquals($contact->citylistCstm->value , 'ab1');
975  $this->assertContains('gg' , $contact->multiselectCstm->values);
976  $this->assertContains('hh' , $contact->multiselectCstm->values);
977  $this->assertContains('reading' , $contact->tagcloudCstm->values);
978  $this->assertContains('surfing' , $contact->tagcloudCstm->values);
980  getByNameAndModelClassName('calcnumber', 'Contact');
981  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $contact);
982  $this->assertEquals(23 , $testCalculatedValue);
983  }
984 
989  {
990  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
991 
992  //Retrieve the super account id and the super user id.
993  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
994  $superUserId = $super->id;
995 
996  //Retrieve the Contact State (Status) Id based on the name.
997  $contactState = ContactState::getByName('RecycledC');
998  $contactStateId = $contactState[0]->id;
999 
1000  //Search a created contact using the customfields.
1001  $this->resetPostArray();
1002  $this->setGetArray(array(
1004  $contactStateId, $superUserId, $accountId),
1005  'ajax' => 'list-view')
1006  );
1007  $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default');
1008 
1009  //Check if the contact name exits after the search is performed on the basis of the
1010  //custom fields added to the contacts module.
1011  //$this->assertContains("Displaying 1-1 of 1 result(s).", $content); //removed until we show the count again in the listview.
1012  $this->assertContains("Sarah Williams Edit", $content);
1013  }
1014 
1019  {
1020  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
1021 
1022  //Retrieve the contact id from the recently edited contact.
1023  $contactId = self::getModelIdByModelNameAndName ('Contact', 'Sarah Williams Edit');
1024 
1025  //Set the contact id so as to delete the contact.
1026  $this->setGetArray(array('id' => $contactId));
1027  $this->runControllerWithRedirectExceptionAndGetUrl('contacts/default/delete');
1028 
1029  //Check whether the contact is deleted.
1030  $contact = Contact::getByName('Sarah Williams Edit');
1031  $this->assertEquals(0, count($contact));
1032  }
1033 
1038  {
1039  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
1040 
1041  //Retrieve the super account id and the super user id.
1042  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
1043  $superUserId = $super->id;
1044 
1045  //Retrieve the Contact State (Status) Id based on the name.
1046  $contactState = ContactState::getByName('RecycledC');
1047  $contactStateId = $contactState[0]->id;
1048 
1049  //Search a created contact using the customfields.
1050  $this->resetPostArray();
1051  $this->setGetArray(array(
1053  $contactStateId, $superUserId, $accountId),
1054  'ajax' => 'list-view')
1055  );
1056  $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default');
1057 
1058  //Assert that the edit contact does not exits after the search.
1059  $this->assertContains("No results found", $content);
1060  $this->assertNotContains("26378 South Arlington Ave", $content);
1061  }
1062 
1067  {
1068  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
1069 
1070  //Search a list item by typing in tag cloud attribute.
1071  $this->resetPostArray();
1072  $this->setGetArray(array('name' => 'tagcloud',
1073  'term' => 'rea'));
1074  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/autoCompleteCustomFieldData');
1075 
1076  //Check if the returned content contains the expected vlaue
1077  $this->assertContains("reading", $content);
1078  }
1079 
1084  {
1085  Yii::app()->user->userModel = User::getByUsername('super');
1086  $languageHelper = new ZurmoLanguageHelper();
1087  $languageHelper->load();
1088  $this->assertEquals('en', $languageHelper->getForCurrentUser());
1089  Yii::app()->user->userModel->language = 'fr';
1090  $this->assertTrue(Yii::app()->user->userModel->save());
1091  $languageHelper->setActive('fr');
1092  $this->assertEquals('fr', Yii::app()->user->getState('language'));
1093 
1094  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
1095 
1096  //Search a list item by typing in tag cloud attribute.
1097  $this->resetPostArray();
1098  $this->setGetArray(array('name' => 'tagcloud',
1099  'term' => 'surf'));
1100  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/autoCompleteCustomFieldData');
1101 
1102  //Check if the returned content contains the expected vlaue
1103  $this->assertContains("surfing fr", $content);
1104  }
1105  }
1106 ?>
static makeBySecurableItem(SecurableItem $securableItem)
static calculateByFormulaAndModelAndResolveFormat($formula, RedBeanModel $model)
static getByUsername($username)
Definition: User.php:49
static getByCode($code)
Definition: Currency.php:90
static getContactsSearchViewLayoutWithAllCustomFieldsPlaced($stateElementName= 'ContactStateDropDown')
runControllerWithRedirectExceptionAndGetContent($route, $compareUrl=null, $compareUrlContains=false)
static fetchContactsSearchFormGetData($contactStateId, $superUserId, $accountId)
static getContactStateDataKeyedByOrder()
static getById($id, $modelClassName=null)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
static getContactsMassEditViewLayoutWithAllStandardAndCustomFieldsPlaced($stateElementName= 'ContactStateDropDown')
static getContactEditAndDetailsViewLayoutWithAllCustomFieldsPlaced($stateElementName= 'ContactStateDropDown')
static getByNameAndModelClassName($name, $modelClassName)
Generated on Thu Aug 6 2020 07:10:29
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.