Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
NotesDesignerSuperUserWalkthroughTest.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 
46  {
47  public static $activateDefaultLanguages = true;
48 
49  public static function setUpBeforeClass()
50  {
51  parent::setUpBeforeClass();
52  SecurityTestHelper::createSuperAdmin();
53  $super = User::getByUsername('super');
54  Yii::app()->user->userModel = $super;
55  Currency::makeBaseCurrency();
56  //Create a account for testing.
57  $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
58 
59  //Create a opportunity for testing.
60  OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp', $super, $account);
61 
62  //Create a two contacts for testing.
63  ContactTestHelper::createContactWithAccountByNameForOwner('superContact1', $super, $account);
64  ContactTestHelper::createContactWithAccountByNameForOwner('superContact2', $super, $account);
65 
66  //Create a note for testing.
67  NoteTestHelper::createNoteWithOwnerAndRelatedAccount('superNote', $super, $account);
68  }
69 
70  public function testSuperUserNoteDefaultControllerActions()
71  {
72  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
73 
74  //Load AttributesList for Note module.
75  $this->setGetArray(array('moduleClassName' => 'NotesModule'));
76  $this->runControllerWithNoExceptionsAndGetContent('designer/default/attributesList');
77 
78  //Load ModuleLayoutsList for Note module.
79  $this->setGetArray(array('moduleClassName' => 'NotesModule'));
80  $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleLayoutsList');
81 
82  //Load ModuleEdit view for each applicable module.
83  $this->setGetArray(array('moduleClassName' => 'NotesModule'));
84  $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleEdit');
85 
86  //Now validate save with failed validation.
87  $this->setGetArray(array('moduleClassName' => 'NotesModule'));
88  $this->setPostArray(array('ajax' => 'edit-form',
89  'NotesModuleForm' => $this->createModuleEditBadValidationPostData()));
90  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/moduleEdit');
91  $this->assertTrue(strlen($content) > 50); //approximate, but should definetely be larger than 50.
92 
93  //Now validate save with successful validation.
94  $this->setGetArray(array('moduleClassName' => 'NotesModule'));
95  $this->setPostArray(array('ajax' => 'edit-form',
96  'NotesModuleForm' => $this->createModuleEditGoodValidationPostData('note new name')));
97  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/moduleEdit');
98  $this->assertEquals('[]', $content);
99 
100  //Now save successfully.
101  $this->setGetArray(array('moduleClassName' => 'NotesModule'));
102  $this->setPostArray(array('save' => 'Save',
103  'NotesModuleForm' => $this->createModuleEditGoodValidationPostData('note new name')));
104  $this->runControllerWithRedirectExceptionAndGetContent('designer/default/moduleEdit');
105 
106  //Now confirm everything did in fact save correctly.
107  $this->assertEquals('Note New Name', NotesModule::getModuleLabelByTypeAndLanguage('Singular'));
108  $this->assertEquals('Note New Names', NotesModule::getModuleLabelByTypeAndLanguage('Plural'));
109  $this->assertEquals('note new name', NotesModule::getModuleLabelByTypeAndLanguage('SingularLowerCase'));
110  $this->assertEquals('note new names', NotesModule::getModuleLabelByTypeAndLanguage('PluralLowerCase'));
111 
112  //Load LayoutEdit for each applicable module and applicable layout
113  $this->resetPostArray();
114  $this->setGetArray(array('moduleClassName' => 'NotesModule',
115  'viewClassName' => 'NoteEditAndDetailsView'));
116  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
117  $this->setGetArray(array('moduleClassName' => 'NotesModule',
118  'viewClassName' => 'NoteInlineEditView'));
119  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
120  }
121 
126  {
127  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
128 
129  //Test create field list.
130  $this->setGetArray(array('moduleClassName' => 'NotesModule'));
131 
132  //View creation screen, then create custom field for each custom field type.
133  $this->createCheckBoxCustomFieldByModule ('NotesModule', 'checkbox');
134  $this->createCurrencyValueCustomFieldByModule ('NotesModule', 'currency');
135  $this->createDateCustomFieldByModule ('NotesModule', 'date');
136  $this->createDateTimeCustomFieldByModule ('NotesModule', 'datetime');
137  $this->createDecimalCustomFieldByModule ('NotesModule', 'decimal');
138  $this->createDropDownCustomFieldByModule ('NotesModule', 'picklist');
139  $this->createDependentDropDownCustomFieldByModule ('NotesModule', 'countrylist');
140  $this->createDependentDropDownCustomFieldByModule ('NotesModule', 'statelist');
141  $this->createDependentDropDownCustomFieldByModule ('NotesModule', 'citylist');
142  $this->createIntegerCustomFieldByModule ('NotesModule', 'integer');
143  $this->createMultiSelectDropDownCustomFieldByModule ('NotesModule', 'multiselect');
144  $this->createTagCloudCustomFieldByModule ('NotesModule', 'tagcloud');
145  $this->createCalculatedNumberCustomFieldByModule ('NotesModule', 'calcnumber');
146  $this->createDropDownDependencyCustomFieldByModule ('NotesModule', 'dropdowndep');
147  $this->createPhoneCustomFieldByModule ('NotesModule', 'phone');
148  $this->createRadioDropDownCustomFieldByModule ('NotesModule', 'radio');
149  $this->createTextCustomFieldByModule ('NotesModule', 'text');
150  $this->createTextAreaCustomFieldByModule ('NotesModule', 'textarea');
151  $this->createUrlCustomFieldByModule ('NotesModule', 'url');
152  }
153 
158  {
159  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
160 
161  //Add custom fields to NoteEditAndDetailsView.
162  $this->setGetArray(array('moduleClassName' => 'NotesModule',
163  'viewClassName' => 'NoteEditAndDetailsView'));
164  $layout = NotesDesignerWalkthroughHelperUtil::getNoteEditAndDetailsViewLayoutWithAllCustomFieldsPlaced();
165  $this->setPostArray(array('save' => 'Save', 'layout' => $layout,
166  'LayoutPanelsTypeForm' => array('type' => FormLayout::PANELS_DISPLAY_TYPE_ALL)));
167  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
168  $this->assertContains('Layout saved successfully', $content);
169 
170  //Add custom fields to NoteInlineEditView.
171  $this->setGetArray(array('moduleClassName' => 'NotesModule',
172  'viewClassName' => 'NoteInlineEditView'));
173  $layout = NotesDesignerWalkthroughHelperUtil::getNoteInlineEditViewLayoutWithAllCustomFieldsPlaced();
174  $this->setPostArray(array('save' => 'Save', 'layout' => $layout,
175  'LayoutPanelsTypeForm' => array('type' => FormLayout::PANELS_DISPLAY_TYPE_ALL)));
176  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
177  $this->assertContains('Layout saved successfully', $content);
178  }
179 
184  {
185  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
186  $superAccountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
187  $superNoteId = self::getModelIdByModelNameAndName ('Note', 'superNote');
188  //Load create, edit, and details views.
189  $this->setGetArray(array('id' => $superNoteId));
190  $this->runControllerWithNoExceptionsAndGetContent('notes/default/edit');
191  $this->setGetArray(array('id' => $superAccountId));
192  $this->resetPostArray();
193  $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
194  $this->setGetArray(array( 'relationAttributeName' => 'Account',
195  'relationModelId' => $superAccountId,
196  'relationModuleId' => 'account',
197  'redirectUrl' => 'someRedirection'));
198  $this->resetPostArray();
199  $this->runControllerWithNoExceptionsAndGetContent('notes/default/createFromRelation');
200  //todo: more permutations from different relations.
201  }
202 
207  {
208  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
209 
210  //Set the date and datetime variable values here.
211  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
212  $dateAssert = date('Y-m-d');
213  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
214  $datetimeAssert = date('Y-m-d H:i:')."00";
215 
216  //Get the super user, account, opportunity and contact id.
217  $superUserId = $super->id;
218  $superAccount = Account::getByName('superAccount');
219  $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact1 superContact1son');
220  $superOpportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpp');
221  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
222 
223  //Create a new note based on the custom fields.
224  $this->resetGetArray();
225  $this->setPostArray(array('Note' => array(
226  'occurredOnDateTime' => $datetime,
227  'description' => 'Note Description',
228  'explicitReadWriteModelPermissions' => array('type' => null),
229  'checkboxCstm' => '1',
230  'currencyCstm' => array('value' => 45,
231  'currency' => array(
232  'id' => $baseCurrency->id)),
233  'dateCstm' => $date,
234  'datetimeCstm' => $datetime,
235  'decimalCstm' => '123',
236  'picklistCstm' => array('value' => 'a'),
237  'multiselectCstm' => array('values' => array('ff', 'rr')),
238  'tagcloudCstm' => array('values' => array('writing', 'gardening')),
239  'countrylistCstm' => array('value' => 'bbbb'),
240  'statelistCstm' => array('value' => 'bbb1'),
241  'citylistCstm' => array('value' => 'bb1'),
242  'integerCstm' => '12',
243  'phoneCstm' => '259-784-2169',
244  'radioCstm' => array('value' => 'd'),
245  'textCstm' => 'This is a test Text',
246  'textareaCstm' => 'This is a test TextArea',
247  'urlCstm' => 'http://wwww.abc.com'),
248  'ActivityItemForm' => array(
249  'Account' => array('id' => $superAccount[0]->id),
250  'Contact' => array('id' => $superContactId),
251  'Opportunity' => array('id' => $superOpportunityId))));
252  $this->runControllerWithRedirectExceptionAndGetUrl('notes/default/inlineCreateSave');
253 
254  //Check the details if they are saved properly for the custom fields.
255  $note = Note::getByName('Note Description');
256 
257  //Retrieve the permission of the note.
258  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
259  makeBySecurableItem(Note::getById($note[0]->id));
260  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
261  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
262 
263  $this->assertEquals($note[0]->description , 'Note Description');
264  $this->assertEquals($note[0]->occurredOnDateTime , $datetimeAssert);
265  $this->assertEquals($note[0]->owner->id , $superUserId);
266  $this->assertEquals($note[0]->activityItems->count() , 3);
267  $this->assertEquals(0 , count($readWritePermitables));
268  $this->assertEquals(0 , count($readOnlyPermitables));
269  $this->assertEquals($note[0]->checkboxCstm , '1');
270  $this->assertEquals($note[0]->currencyCstm->value , 45);
271  $this->assertEquals($note[0]->currencyCstm->currency->id , $baseCurrency->id);
272  $this->assertEquals($note[0]->dateCstm , $dateAssert);
273  $this->assertEquals($note[0]->datetimeCstm , $datetimeAssert);
274  $this->assertEquals($note[0]->decimalCstm , '123');
275  $this->assertEquals($note[0]->picklistCstm->value , 'a');
276  $this->assertEquals($note[0]->integerCstm , 12);
277  $this->assertEquals($note[0]->phoneCstm , '259-784-2169');
278  $this->assertEquals($note[0]->radioCstm->value , 'd');
279  $this->assertEquals($note[0]->textCstm , 'This is a test Text');
280  $this->assertEquals($note[0]->textareaCstm , 'This is a test TextArea');
281  $this->assertEquals($note[0]->urlCstm , 'http://wwww.abc.com');
282  $this->assertEquals($note[0]->countrylistCstm->value , 'bbbb');
283  $this->assertEquals($note[0]->statelistCstm->value , 'bbb1');
284  $this->assertEquals($note[0]->citylistCstm->value , 'bb1');
285  $this->assertContains('ff' , $note[0]->multiselectCstm->values);
286  $this->assertContains('rr' , $note[0]->multiselectCstm->values);
287  $this->assertContains('writing' , $note[0]->tagcloudCstm->values);
288  $this->assertContains('gardening' , $note[0]->tagcloudCstm->values);
290  getByNameAndModelClassName('calcnumber', 'Note');
291  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $note[0]);
292  $this->assertEquals(135 , $testCalculatedValue);
293  }
294 
299  {
300  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
301 
302  //Set the date and datetime variable values here.
303  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
304  $dateAssert = date('Y-m-d');
305  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
306  $datetimeAssert = date('Y-m-d H:i:')."00";
307 
308  //Get the super user, account, opportunity and contact id.
309  $superUserId = $super->id;
310  $superAccount = Account::getByName('superAccount');
311  $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact2 superContact2son');
312  $superOpportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpp');
313  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
314  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
315 
316  //Retrieve the note Id based on the created note.
317  $note = Note::getByName('Note Description');
318  $this->assertEquals(2, $note[0]->tagcloudCstm->values->count());
319 
320  //Edit a note based on the custom fields.
321  $this->setGetArray(array('id' => $note[0]->id));
322  $this->setPostArray(array('Note' => array(
323  'occurredOnDateTime' => $datetime,
324  'description' => 'Note Edit Description',
325  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
326  'owner' => array('id' => $superUserId),
327  'checkboxCstm' => '0',
328  'currencyCstm' => array('value' => 40,
329  'currency' => array(
330  'id' => $baseCurrency->id)),
331  'dateCstm' => $date,
332  'datetimeCstm' => $datetime,
333  'decimalCstm' => '12',
334  'picklistCstm' => array('value' => 'b'),
335  'multiselectCstm' => array('values' => array('gg', 'hh')),
336  'tagcloudCstm' => array('values' => array('writing')),
337  'countrylistCstm' => array('value' => 'aaaa'),
338  'statelistCstm' => array('value' => 'aaa1'),
339  'citylistCstm' => array('value' => 'ab1'),
340  'integerCstm' => '11',
341  'phoneCstm' => '259-784-2069',
342  'radioCstm' => array('value' => 'e'),
343  'textCstm' => 'This is a test Edit Text',
344  'textareaCstm' => 'This is a test Edit TextArea',
345  'urlCstm' => 'http://wwww.abc-edit.com'),
346  'ActivityItemForm' => array(
347  'Account' => array('id' => $superAccount[0]->id),
348  'Contact' => array('id' => $superContactId),
349  'Opportunity' => array('id' => $superOpportunityId))));
350  $this->runControllerWithRedirectExceptionAndGetUrl('notes/default/edit');
351 
352  //Check the details if they are saved properly for the custom fields.
353  $note = Note::getByName('Note Edit Description');
354 
355  //Retrieve the permission of the note.
356  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
357  makeBySecurableItem(Note::getById($note[0]->id));
358  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
359  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
360 
361  $this->assertEquals($note[0]->description , 'Note Edit Description');
362  $this->assertEquals($note[0]->occurredOnDateTime , $datetimeAssert);
363  $this->assertEquals($note[0]->owner->id , $superUserId);
364  $this->assertEquals($note[0]->activityItems->count() , 3);
365  $this->assertEquals(1 , count($readWritePermitables));
366  $this->assertEquals(0 , count($readOnlyPermitables));
367  $this->assertEquals($note[0]->checkboxCstm , '0');
368  $this->assertEquals($note[0]->currencyCstm->value , 40);
369  $this->assertEquals($note[0]->currencyCstm->currency->id , $baseCurrency->id);
370  $this->assertEquals($note[0]->dateCstm , $dateAssert);
371  $this->assertEquals($note[0]->datetimeCstm , $datetimeAssert);
372  $this->assertEquals($note[0]->decimalCstm , '12');
373  $this->assertEquals($note[0]->picklistCstm->value , 'b');
374  $this->assertEquals($note[0]->integerCstm , 11);
375  $this->assertEquals($note[0]->phoneCstm , '259-784-2069');
376  $this->assertEquals($note[0]->radioCstm->value , 'e');
377  $this->assertEquals($note[0]->textCstm , 'This is a test Edit Text');
378  $this->assertEquals($note[0]->textareaCstm , 'This is a test Edit TextArea');
379  $this->assertEquals($note[0]->urlCstm , 'http://wwww.abc-edit.com');
380  $this->assertEquals($note[0]->countrylistCstm->value , 'aaaa');
381  $this->assertEquals($note[0]->statelistCstm->value , 'aaa1');
382  $this->assertEquals($note[0]->citylistCstm->value , 'ab1');
383  $this->assertContains('gg' , $note[0]->multiselectCstm->values);
384  $this->assertContains('hh' , $note[0]->multiselectCstm->values);
385  $this->assertEquals(1 , $note[0]->tagcloudCstm->values->count());
387  getByNameAndModelClassName('calcnumber', 'Note');
388  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $note[0]);
389  $this->assertEquals(23 , $testCalculatedValue);
390  }
391 
396  {
397  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
398 
399  //Set the date and datetime variable values here.
400  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
401  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
402 
403  //Get the super user, account, opportunity and contact id.
404  $superUserId = $super->id;
405  $superAccount = Account::getByName('superAccount');
406  $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact2 superContact2son');
407  $superOpportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpp');
408  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
409  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
410 
411  //Retrieve the note Id based on the created note.
412  $note = Note::getByName('Note Edit Description');
413  $this->assertEquals(1, $note[0]->tagcloudCstm->values->count());
414 
415  //Edit a note based on the custom fields.
416  $this->setGetArray(array('id' => $note[0]->id));
417  $this->setPostArray(array('Note' => array(
418  'occurredOnDateTime' => $datetime,
419  'description' => 'Note Edit Description',
420  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
421  'owner' => array('id' => $superUserId),
422  'checkboxCstm' => '0',
423  'currencyCstm' => array('value' => 40,
424  'currency' => array(
425  'id' => $baseCurrency->id)),
426  'dateCstm' => $date,
427  'datetimeCstm' => $datetime,
428  'decimalCstm' => '12',
429  'picklistCstm' => array('value' => 'b'),
430  'multiselectCstm' => array('values' => array('gg', 'hh')),
431  'tagcloudCstm' => array('values' => array()),
432  'countrylistCstm' => array('value' => 'aaaa'),
433  'statelistCstm' => array('value' => 'aaa1'),
434  'citylistCstm' => array('value' => 'ab1'),
435  'integerCstm' => '11',
436  'phoneCstm' => '259-784-2069',
437  'radioCstm' => array('value' => 'e'),
438  'textCstm' => 'This is a test Edit Text',
439  'textareaCstm' => 'This is a test Edit TextArea',
440  'urlCstm' => 'http://wwww.abc-edit.com'),
441  'ActivityItemForm' => array(
442  'Account' => array('id' => $superAccount[0]->id),
443  'Contact' => array('id' => $superContactId),
444  'Opportunity' => array('id' => $superOpportunityId))));
445  $content = $this->runControllerWithNoExceptionsAndGetContent('notes/default/edit');
446  $this->assertContains("tagcloud en cannot be blank.", $content);
447  }
448 
453  {
454  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
455 
456  //Set the date and datetime variable values here.
457  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
458  $dateAssert = date('Y-m-d');
459  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
460  $datetimeAssert = date('Y-m-d H:i:')."00";
461 
462  //Get the super user, account, opportunity and contact id.
463  $superUserId = $super->id;
464  $superAccount = Account::getByName('superAccount');
465  $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact2 superContact2son');
466  $superOpportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpp');
467  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
468  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
469 
470  //Retrieve the note Id based on the created note.
471  $note = Note::getByName('Note Edit Description');
472 
473  //Edit a note based on the custom fields.
474  $this->setGetArray(array('id' => $note[0]->id));
475  $this->setPostArray(array('Note' => array(
476  'occurredOnDateTime' => $datetime,
477  'description' => 'Note Edit Description',
478  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
479  'owner' => array('id' => $superUserId),
480  'checkboxCstm' => '0',
481  'currencyCstm' => array('value' => 40,
482  'currency' => array(
483  'id' => $baseCurrency->id)),
484  'dateCstm' => $date,
485  'datetimeCstm' => $datetime,
486  'decimalCstm' => '12',
487  'picklistCstm' => array('value' => 'b'),
488  'multiselectCstm' => array('values' => array('gg', 'hh')),
489  'tagcloudCstm' => array('values' => array('reading', 'surfing')),
490  'countrylistCstm' => array('value' => 'aaaa'),
491  'statelistCstm' => array('value' => 'aaa1'),
492  'citylistCstm' => array('value' => 'ab1'),
493  'integerCstm' => '11',
494  'phoneCstm' => '259-784-2069',
495  'radioCstm' => array('value' => 'e'),
496  'textCstm' => 'This is a test Edit Text',
497  'textareaCstm' => 'This is a test Edit TextArea',
498  'urlCstm' => 'http://wwww.abc-edit.com'),
499  'ActivityItemForm' => array(
500  'Account' => array('id' => $superAccount[0]->id),
501  'Contact' => array('id' => $superContactId),
502  'Opportunity' => array('id' => $superOpportunityId))));
503  $this->runControllerWithRedirectExceptionAndGetUrl('notes/default/edit');
504 
505  //Check the details if they are saved properly for the custom fields.
506  $note = Note::getByName('Note Edit Description');
507 
508  //Retrieve the permission of the note.
509  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
510  makeBySecurableItem(Note::getById($note[0]->id));
511  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
512  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
513 
514  $this->assertEquals($note[0]->description , 'Note Edit Description');
515  $this->assertEquals($note[0]->occurredOnDateTime , $datetimeAssert);
516  $this->assertEquals($note[0]->owner->id , $superUserId);
517  $this->assertEquals($note[0]->activityItems->count() , 3);
518  $this->assertEquals(1 , count($readWritePermitables));
519  $this->assertEquals(0 , count($readOnlyPermitables));
520  $this->assertEquals($note[0]->checkboxCstm , '0');
521  $this->assertEquals($note[0]->currencyCstm->value , 40);
522  $this->assertEquals($note[0]->currencyCstm->currency->id , $baseCurrency->id);
523  $this->assertEquals($note[0]->dateCstm , $dateAssert);
524  $this->assertEquals($note[0]->datetimeCstm , $datetimeAssert);
525  $this->assertEquals($note[0]->decimalCstm , '12');
526  $this->assertEquals($note[0]->picklistCstm->value , 'b');
527  $this->assertEquals($note[0]->integerCstm , 11);
528  $this->assertEquals($note[0]->phoneCstm , '259-784-2069');
529  $this->assertEquals($note[0]->radioCstm->value , 'e');
530  $this->assertEquals($note[0]->textCstm , 'This is a test Edit Text');
531  $this->assertEquals($note[0]->textareaCstm , 'This is a test Edit TextArea');
532  $this->assertEquals($note[0]->urlCstm , 'http://wwww.abc-edit.com');
533  $this->assertEquals($note[0]->countrylistCstm->value , 'aaaa');
534  $this->assertEquals($note[0]->statelistCstm->value , 'aaa1');
535  $this->assertEquals($note[0]->citylistCstm->value , 'ab1');
536  $this->assertContains('gg' , $note[0]->multiselectCstm->values);
537  $this->assertContains('hh' , $note[0]->multiselectCstm->values);
538  $this->assertContains('reading' , $note[0]->tagcloudCstm->values);
539  $this->assertContains('surfing' , $note[0]->tagcloudCstm->values);
541  getByNameAndModelClassName('calcnumber', 'Note');
542  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $note[0]);
543  $this->assertEquals(23 , $testCalculatedValue);
544  }
545 
550  {
551  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
552 
553  //Retrieve the note Id based on the created note.
554  $note = Note::getByName('Note Edit Description');
555 
556  //Set the note id so as to delete the note.
557  $this->setGetArray(array('id' => $note[0]->id));
558  $this->runControllerWithRedirectExceptionAndGetUrl('notes/default/delete');
559 
560  //Check to confirm that the note is deleted.
561  $note = Note::getByName('Note Edit Description');
562  $this->assertEquals(0, count($note));
563  }
564 
569  {
570  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
571 
572  //Search a list item by typing in tag cloud attribute.
573  $this->resetPostArray();
574  $this->setGetArray(array('name' => 'tagcloud',
575  'term' => 'rea'));
576  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/autoCompleteCustomFieldData');
577 
578  //Check if the returned content contains the expected vlaue
579  $this->assertContains("reading", $content);
580  }
581 
586  {
587  Yii::app()->user->userModel = User::getByUsername('super');
588  $languageHelper = new ZurmoLanguageHelper();
589  $languageHelper->load();
590  $this->assertEquals('en', $languageHelper->getForCurrentUser());
591  Yii::app()->user->userModel->language = 'fr';
592  $this->assertTrue(Yii::app()->user->userModel->save());
593  $languageHelper->setActive('fr');
594  $this->assertEquals('fr', Yii::app()->user->getState('language'));
595 
596  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
597 
598  //Search a list item by typing in tag cloud attribute.
599  $this->resetPostArray();
600  $this->setGetArray(array('name' => 'tagcloud',
601  'term' => 'surf'));
602  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/autoCompleteCustomFieldData');
603 
604  //Check if the returned content contains the expected vlaue
605  $this->assertContains("surfing fr", $content);
606  }
607  }
608 ?>
static makeBySecurableItem(SecurableItem $securableItem)
static calculateByFormulaAndModelAndResolveFormat($formula, RedBeanModel $model)
static getByUsername($username)
Definition: User.php:49
static getByCode($code)
Definition: Currency.php:90
runControllerWithRedirectExceptionAndGetContent($route, $compareUrl=null, $compareUrlContains=false)
static getById($id, $modelClassName=null)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
static getByNameAndModelClassName($name, $modelClassName)
Generated on Fri Sep 25 2020 07:10:33
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.