Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.
 All Data Structures Functions Variables Pages
ProductsDesignerSuperUserWalkthroughTest.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 
58  //Create a Product for testing.
59  ProductTestHelper::createProductByNameForOwner('superProduct', $super);
60 
61  //Create a account for testing.
62  $account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
63  }
64 
65  public function testSuperUserProductDefaultControllerActions()
66  {
67  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
68 
69  //Default Controller actions requiring some sort of parameter via POST or GET
70  //Load Product Modules Menu.
71  $this->setGetArray(array('moduleClassName' => 'ProductsModule'));
72  $this->runControllerWithNoExceptionsAndGetContent('designer/default/modulesMenu');
73 
74  //Load AttributesList for Product module.
75  $this->setGetArray(array('moduleClassName' => 'ProductsModule'));
76  $this->runControllerWithNoExceptionsAndGetContent('designer/default/attributesList');
77 
78  //Load ModuleLayoutsList for Product module.
79  $this->setGetArray(array('moduleClassName' => 'ProductsModule'));
80  $this->runControllerWithNoExceptionsAndGetContent('designer/default/moduleLayoutsList');
81 
82  //Now confirm everything did in fact save correctly.
83  $this->assertEquals('Product', ProductsModule::getModuleLabelByTypeAndLanguage('Singular'));
84  $this->assertEquals('Products', ProductsModule::getModuleLabelByTypeAndLanguage('Plural'));
85  $this->assertEquals('product', ProductsModule::getModuleLabelByTypeAndLanguage('SingularLowerCase'));
86  $this->assertEquals('products', ProductsModule::getModuleLabelByTypeAndLanguage('PluralLowerCase'));
87 
88  //Load LayoutEdit for each applicable module and applicable layout
89  $this->resetPostArray();
90  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
91  'viewClassName' => 'ProductsListView'));
92  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
93  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
94  'viewClassName' => 'ProductsModalListView'));
95  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
96  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
97  'viewClassName' => 'ProductsModalSearchView'));
98  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
99  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
100  'viewClassName' => 'ProductsRelatedListView'));
101  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
102  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
103  'viewClassName' => 'ProductEditAndDetailsView'));
104  $this->runControllerWithNoExceptionsAndGetContent('designer/default/LayoutEdit');
105  }
106 
111  {
112  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
113 
114  //Test create field list.
115  $this->setGetArray(array('moduleClassName' => 'ProductsModule'));
116 
117  //View creation screen, then create custom field for each custom field type.
118  $this->createCheckBoxCustomFieldByModule ('ProductsModule', 'checkbox');
119  $this->createCurrencyValueCustomFieldByModule ('ProductsModule', 'currency');
120  $this->createDateCustomFieldByModule ('ProductsModule', 'date');
121  $this->createDateTimeCustomFieldByModule ('ProductsModule', 'datetime');
122  $this->createDecimalCustomFieldByModule ('ProductsModule', 'decimal');
123  $this->createDropDownCustomFieldByModule ('ProductsModule', 'picklist');
124  $this->createDependentDropDownCustomFieldByModule ('ProductsModule', 'countrylist');
125  $this->createDependentDropDownCustomFieldByModule ('ProductsModule', 'statelist');
126  $this->createDependentDropDownCustomFieldByModule ('ProductsModule', 'citylist');
127  $this->createIntegerCustomFieldByModule ('ProductsModule', 'integer');
128  $this->createMultiSelectDropDownCustomFieldByModule ('ProductsModule', 'multiselect');
129  $this->createTagCloudCustomFieldByModule ('ProductsModule', 'tagcloud');
130  $this->createCalculatedNumberCustomFieldByModule ('ProductsModule', 'calcnumber');
131  $this->createDropDownDependencyCustomFieldByModule ('ProductsModule', 'dropdowndep');
132  $this->createPhoneCustomFieldByModule ('ProductsModule', 'phone');
133  $this->createRadioDropDownCustomFieldByModule ('ProductsModule', 'radio');
134  $this->createTextCustomFieldByModule ('ProductsModule', 'text');
135  $this->createTextAreaCustomFieldByModule ('ProductsModule', 'textarea');
136  $this->createUrlCustomFieldByModule ('ProductsModule', 'url');
137  }
138 
143  {
144  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
145 
146  //Add custom fields to ProductEditAndDetailsView.
147  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
148  'viewClassName' => 'ProductEditAndDetailsView'));
149  $layout = ProductsDesignerWalkthroughHelperUtil::getProductEditAndDetailsViewLayoutWithAllCustomFieldsPlaced();
150  $this->setPostArray(array('save' => 'Save', 'layout' => $layout,
151  'LayoutPanelsTypeForm' => array('type' => FormLayout::PANELS_DISPLAY_TYPE_ALL)));
152  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
153  $this->assertContains('Layout saved successfully', $content);
154 
155  //Add all fields to OpportunitiesSearchView.
156  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
157  'viewClassName' => 'ProductsSearchView'));
158  $layout = ProductsDesignerWalkthroughHelperUtil::getProductsSearchViewLayoutWithAllCustomFieldsPlaced();
159  $this->setPostArray(array('save' => 'Save', 'layout' => $layout));
160  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
161  $this->assertContains('Layout saved successfully', $content);
162 
163  //Add all fields to OpportunitiesListView.
164  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
165  'viewClassName' => 'ProductsListView'));
167  $this->setPostArray(array('save' => 'Save', 'layout' => $layout));
168  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
169  $this->assertContains('Layout saved successfully', $content);
170 
171  //Add all fields to OpportunitiesRelatedListView.
172  $this->setGetArray(array('moduleClassName' => 'ProductsModule',
173  'viewClassName' => 'ProductsRelatedListView'));
175  $this->setPostArray(array('save' => 'Save', 'layout' => $layout));
176  $content = $this->runControllerWithExitExceptionAndGetContent('designer/default/LayoutEdit');
177  $this->assertContains('Layout saved successfully', $content);
178  }
179 
184  {
185  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
186  $superProductId = self::getModelIdByModelNameAndName ('Product', 'superProduct');
187  //Load create, edit, and details views.
188  $this->runControllerWithNoExceptionsAndGetContent('products/default/create');
189  $this->setGetArray(array('id' => $superProductId));
190  $this->runControllerWithNoExceptionsAndGetContent('products/default/edit');
191  $this->runControllerWithNoExceptionsAndGetContent('products/default/details');
192  $this->runControllerWithNoExceptionsAndGetContent('products/default/list');
193  }
194 
199  {
200  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
201 
202  //Set the date and datetime variable values here.
203  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
204  $dateAssert = date('Y-m-d');
205  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
206  $datetimeAssert = date('Y-m-d H:i:')."00";
207  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
208  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
209  //Retrieve the account id and the super account id.
210  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
211  $superUserId = $super->id;
212 
213  //Create a new product based on the custom fields.
214  $this->resetGetArray();
215  $this->setPostArray(array('Product' => array(
216  'name' => 'myNewProduct',
217  'owner' => array('id' => $superUserId),
218  'type' => 1,
219  'sellPrice' => array ('currency' => array ('id' => $baseCurrency->id), 'value' => 200),
220  'account' => array('id' => $accountId),
221  'quantity' => 10,
222  'priceFrequency' => 2,
223  'stage' => array('value' => 'Open'),
224  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
225  'checkboxCstm' => '1',
226  'currencyCstm' => array('value' => 45,
227  'currency' => array('id' => $baseCurrency->id)),
228  'dateCstm' => $date,
229  'datetimeCstm' => $datetime,
230  'decimalCstm' => '123',
231  'picklistCstm' => array('value' => 'a'),
232  'multiselectCstm' => array('values' => array('ff', 'rr')),
233  'tagcloudCstm' => array('values' => array('writing', 'gardening')),
234  'countrylistCstm' => array('value' => 'bbbb'),
235  'statelistCstm' => array('value' => 'bbb1'),
236  'citylistCstm' => array('value' => 'bb1'),
237  'integerCstm' => '12',
238  'phoneCstm' => '259-784-2169',
239  'radioCstm' => array('value' => 'd'),
240  'textCstm' => 'This is a test Text',
241  'textareaCstm' => 'This is a test TextArea',
242  'urlCstm' => 'http://wwww.abc.com')));
243  $this->runControllerWithRedirectExceptionAndGetUrl('products/default/create');
244 
245  //Check the details if they are saved properly for the custom fields.
246  $productId = self::getModelIdByModelNameAndName('Product', 'myNewProduct');
247  $product = Product::getById($productId);
248 
249  //Retrieve the permission of the product.
250  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
251  makeBySecurableItem($product);
252  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
253  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
254 
255  $this->assertEquals($product->name , 'myNewProduct');
256  $this->assertEquals($product->quantity , 10);
257  $this->assertEquals($product->sellPrice->value , 200.00);
258  $this->assertEquals($product->account->id , $accountId);
259  $this->assertEquals($product->type , 1);
260  $this->assertEquals($product->stage->value , 'Open');
261  $this->assertEquals($product->owner->id , $superUserId);
262  $this->assertEquals(1 , count($readWritePermitables));
263  $this->assertEquals(0 , count($readOnlyPermitables));
264  $this->assertEquals($product->checkboxCstm , '1');
265  $this->assertEquals($product->currencyCstm->value , 45);
266  $this->assertEquals($product->currencyCstm->currency->id , $baseCurrency->id);
267  $this->assertEquals($product->dateCstm , $dateAssert);
268  $this->assertEquals($product->datetimeCstm , $datetimeAssert);
269  $this->assertEquals($product->decimalCstm , '123');
270  $this->assertEquals($product->picklistCstm->value , 'a');
271  $this->assertEquals($product->integerCstm , 12);
272  $this->assertEquals($product->phoneCstm , '259-784-2169');
273  $this->assertEquals($product->radioCstm->value , 'd');
274  $this->assertEquals($product->textCstm , 'This is a test Text');
275  $this->assertEquals($product->textareaCstm , 'This is a test TextArea');
276  $this->assertEquals($product->urlCstm , 'http://wwww.abc.com');
277  $this->assertEquals($product->countrylistCstm->value , 'bbbb');
278  $this->assertEquals($product->statelistCstm->value , 'bbb1');
279  $this->assertEquals($product->citylistCstm->value , 'bb1');
280  $this->assertContains('ff' , $product->multiselectCstm->values);
281  $this->assertContains('rr' , $product->multiselectCstm->values);
282  $this->assertContains('writing' , $product->tagcloudCstm->values);
283  $this->assertContains('gardening' , $product->tagcloudCstm->values);
285  getByNameAndModelClassName('calcnumber', 'Product');
286  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $product);
287  $this->assertEquals(1476 , intval(str_replace(',', '', $testCalculatedValue))); // Not Coding Standard
288  }
289 
294  {
295  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
296 
297  //Retrieve the account id and the super user id.
298  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
299  $superUserId = $super->id;
300 
301  //Search a created product using the customfield.
302  $this->resetPostArray();
303  $this->setGetArray(array('ProductsSearchForm' => array(
304  'name' => 'myNewProduct',
305  'owner' => array('id' => $superUserId),
306  'type' => 1,
307  'sellPrice' => array ('value' => 200),
308  'account' => array('id' => $accountId),
309  'quantity' => 10,
310  'priceFrequency' => 2,
311  'stage' => array('value' => 'Open'),
312  'decimalCstm' => '123',
313  'integerCstm' => '12',
314  'phoneCstm' => '259-784-2169',
315  'textCstm' => 'This is a test Text',
316  'textareaCstm' => 'This is a test TextArea',
317  'urlCstm' => 'http://wwww.abc.com',
318  'checkboxCstm' => array('value' => '1'),
319  'currencyCstm' => array('value' => 45),
320  'picklistCstm' => array('value' => 'a'),
321  'multiselectCstm' => array('values' => array('ff', 'rr')),
322  'tagcloudCstm' => array('values' => array('writing', 'gardening')),
323  'countrylistCstm' => array('value' => 'bbbb'),
324  'statelistCstm' => array('value' => 'bbb1'),
325  'citylistCstm' => array('value' => 'bb1'),
326  'radioCstm' => array('value' => 'd'),
327  'dateCstm__Date' => array('type' => 'Today'),
328  'datetimeCstm__DateTime' => array('type' => 'Today')),
329  'ajax' => 'list-view'));
330  $content = $this->runControllerWithNoExceptionsAndGetContent('products/default');
331  $this->assertContains("myNewProduct", $content);
332  }
333 
338  {
339  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
340 
341  //Set the date and datetime variable values here.
342  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
343  $dateAssert = date('Y-m-d');
344  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
345  $datetimeAssert = date('Y-m-d H:i:')."00";
346  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
347 
348  //Retrieve the account id, the super user id and product Id.
349  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
350  $superUserId = $super->id;
351  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
352  $product = Product::getByName('myNewProduct');
353  $productId = $product[0]->id;
354  $this->assertEquals(2, $product[0]->tagcloudCstm->values->count());
355 
356  //Edit a new Product based on the custom fields.
357  $this->setGetArray(array('id' => $productId));
358  $this->setPostArray(array('Product' => array(
359  'name' => 'myEditProduct',
360  'owner' => array('id' => $superUserId),
361  'type' => 1,
362  'sellPrice' => array ('currency' => array('id' => $baseCurrency->id), 'value' => 200),
363  'account' => array('id' => $accountId),
364  'quantity' => 10,
365  'priceFrequency' => 2,
366  'stage' => array('value' => 'Open'),
367  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
368  'checkboxCstm' => '0',
369  'currencyCstm' => array('value' => 40,
370  'currency' => array(
371  'id' => $baseCurrency->id)),
372  'decimalCstm' => '12',
373  'dateCstm' => $date,
374  'datetimeCstm' => $datetime,
375  'picklistCstm' => array('value' => 'b'),
376  'multiselectCstm' => array('values' => array('gg', 'hh')),
377  'tagcloudCstm' => array('values' => array('writing')),
378  'countrylistCstm' => array('value' => 'aaaa'),
379  'statelistCstm' => array('value' => 'aaa1'),
380  'citylistCstm' => array('value' => 'ab1'),
381  'integerCstm' => '11',
382  'phoneCstm' => '259-784-2069',
383  'radioCstm' => array('value' => 'e'),
384  'textCstm' => 'This is a test Edit Text',
385  'textareaCstm' => 'This is a test Edit TextArea',
386  'urlCstm' => 'http://wwww.abc-edit.com')));
387  $this->runControllerWithRedirectExceptionAndGetUrl('products/default/edit');
388 
389  //Check the details if they are saved properly for the custom fields.
390  $productId = self::getModelIdByModelNameAndName('Product', 'myEditProduct');
391  $product = Product::getById($productId);
392 
393  //Retrieve the permission of the product.
394  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
395  makeBySecurableItem($product);
396  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
397  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
398 
399  $this->assertEquals($product->name , 'myEditProduct');
400  $this->assertEquals($product->quantity , 10);
401  $this->assertEquals($product->sellPrice->value , 200.00);
402  $this->assertEquals($product->account->id , $accountId);
403  $this->assertEquals($product->type , 1);
404  $this->assertEquals($product->stage->value , 'Open');
405  $this->assertEquals($product->owner->id , $superUserId);
406  $this->assertEquals(1 , count($readWritePermitables));
407  $this->assertEquals(0 , count($readOnlyPermitables));
408  $this->assertEquals($product->checkboxCstm , '0');
409  $this->assertEquals($product->currencyCstm->value , 40);
410  $this->assertEquals($product->currencyCstm->currency->id , $baseCurrency->id);
411  $this->assertEquals($product->dateCstm , $dateAssert);
412  $this->assertEquals($product->datetimeCstm , $datetimeAssert);
413  $this->assertEquals($product->decimalCstm , '12');
414  $this->assertEquals($product->picklistCstm->value , 'b');
415  $this->assertEquals($product->integerCstm , 11);
416  $this->assertEquals($product->phoneCstm , '259-784-2069');
417  $this->assertEquals($product->radioCstm->value , 'e');
418  $this->assertEquals($product->textCstm , 'This is a test Edit Text');
419  $this->assertEquals($product->textareaCstm , 'This is a test Edit TextArea');
420  $this->assertEquals($product->urlCstm , 'http://wwww.abc-edit.com');
421  $this->assertEquals($product->dateCstm , $dateAssert);
422  $this->assertEquals($product->datetimeCstm , $datetimeAssert);
423  $this->assertEquals($product->countrylistCstm->value , 'aaaa');
424  $this->assertEquals($product->statelistCstm->value , 'aaa1');
425  $this->assertEquals($product->citylistCstm->value , 'ab1');
426  $this->assertContains('gg' , $product->multiselectCstm->values);
427  $this->assertContains('hh' , $product->multiselectCstm->values);
428  $this->assertEquals(1 , $product->tagcloudCstm->values->count());
430  getByNameAndModelClassName('calcnumber', 'Product');
431  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $product);
432  $this->assertEquals(132 , intval(str_replace(',', '', $testCalculatedValue))); // Not Coding Standard
433  }
434 
439  {
440  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
441 
442  //Set the date and datetime variable values here.
443  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
444  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
445  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
446 
447  //Retrieve the account id, the super user id and product Id.
448  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
449  $superUserId = $super->id;
450  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
451  $product = Product::getByName('myEditProduct');
452  $productId = $product[0]->id;
453  $this->assertEquals(1, $product[0]->tagcloudCstm->values->count());
454 
455  //Edit a new Product based on the custom fields.
456  $this->setGetArray(array('id' => $productId));
457  $this->setPostArray(array('Product' => array(
458  'name' => 'myEditProduct',
459  'owner' => array('id' => $superUserId),
460  'type' => 1,
461  'sellPrice' => array ('currency' => array('id' => $baseCurrency->id), 'value' => 200),
462  'account' => array('id' => $accountId),
463  'quantity' => 10,
464  'priceFrequency' => 2,
465  'stage' => array('value' => 'Open'),
466  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
467  'checkboxCstm' => '0',
468  'currencyCstm' => array('value' => 40,
469  'currency' => array(
470  'id' => $baseCurrency->id)),
471  'decimalCstm' => '12',
472  'dateCstm' => $date,
473  'datetimeCstm' => $datetime,
474  'picklistCstm' => array('value' => 'b'),
475  'multiselectCstm' => array('values' => array('gg', 'hh')),
476  'tagcloudCstm' => array('values' => array()),
477  'countrylistCstm' => array('value' => 'aaaa'),
478  'statelistCstm' => array('value' => 'aaa1'),
479  'citylistCstm' => array('value' => 'ab1'),
480  'integerCstm' => '11',
481  'phoneCstm' => '259-784-2069',
482  'radioCstm' => array('value' => 'e'),
483  'textCstm' => 'This is a test Edit Text',
484  'textareaCstm' => 'This is a test Edit TextArea',
485  'urlCstm' => 'http://wwww.abc-edit.com')));
486  $content = $this->runControllerWithNoExceptionsAndGetContent('products/default/edit');
487  $this->assertContains("tagcloud en cannot be blank.", $content);
488  }
489 
494  {
495  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
496 
497  //Set the date and datetime variable values here.
498  $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormatForInput(), time());
499  $dateAssert = date('Y-m-d');
500  $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormatForInput(), time());
501  $datetimeAssert = date('Y-m-d H:i:')."00";
502  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
503 
504  //Retrieve the account id, the super user id and product Id.
505  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
506  $superUserId = $super->id;
507  $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
508  $product = Product::getByName('myEditProduct');
509  $productId = $product[0]->id;
510 
511  //Edit a new Product based on the custom fields.
512  $this->setGetArray(array('id' => $productId));
513  $this->setPostArray(array('Product' => array(
514  'name' => 'myEditProduct',
515  'owner' => array('id' => $superUserId),
516  'type' => 1,
517  'sellPrice' => array ('currency' => array('id' => $baseCurrency->id), 'value' => 200),
518  'account' => array('id' => $accountId),
519  'quantity' => 10,
520  'priceFrequency' => 2,
521  'stage' => array('value' => 'Open'),
522  'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission),
523  'checkboxCstm' => '0',
524  'currencyCstm' => array('value' => 40,
525  'currency' => array(
526  'id' => $baseCurrency->id)),
527  'decimalCstm' => '12',
528  'dateCstm' => $date,
529  'datetimeCstm' => $datetime,
530  'picklistCstm' => array('value' => 'b'),
531  'multiselectCstm' => array('values' => array('gg', 'hh')),
532  'tagcloudCstm' => array('values' => array('reading', 'surfing')),
533  'countrylistCstm' => array('value' => 'aaaa'),
534  'statelistCstm' => array('value' => 'aaa1'),
535  'citylistCstm' => array('value' => 'ab1'),
536  'integerCstm' => '11',
537  'phoneCstm' => '259-784-2069',
538  'radioCstm' => array('value' => 'e'),
539  'textCstm' => 'This is a test Edit Text',
540  'textareaCstm' => 'This is a test Edit TextArea',
541  'urlCstm' => 'http://wwww.abc-edit.com')));
542  $this->runControllerWithRedirectExceptionAndGetUrl('products/default/edit');
543 
544  //Check the details if they are saved properly for the custom fields.
545  $productId = self::getModelIdByModelNameAndName('Product', 'myEditProduct');
546  $product = Product::getById($productId);
547 
548  //Retrieve the permission of the product.
549  $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::
550  makeBySecurableItem($product);
551  $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
552  $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
553 
554  $this->assertEquals($product->name , 'myEditProduct');
555  $this->assertEquals($product->quantity , 10);
556  $this->assertEquals($product->sellPrice->value , 200.00);
557  $this->assertEquals($product->account->id , $accountId);
558  $this->assertEquals($product->type , 1);
559  $this->assertEquals($product->stage->value , 'Open');
560  $this->assertEquals($product->owner->id , $superUserId);
561  $this->assertEquals(1 , count($readWritePermitables));
562  $this->assertEquals(0 , count($readOnlyPermitables));
563  $this->assertEquals($product->checkboxCstm , '0');
564  $this->assertEquals($product->currencyCstm->value , 40);
565  $this->assertEquals($product->currencyCstm->currency->id , $baseCurrency->id);
566  $this->assertEquals($product->dateCstm , $dateAssert);
567  $this->assertEquals($product->datetimeCstm , $datetimeAssert);
568  $this->assertEquals($product->decimalCstm , '12');
569  $this->assertEquals($product->picklistCstm->value , 'b');
570  $this->assertEquals($product->integerCstm , 11);
571  $this->assertEquals($product->phoneCstm , '259-784-2069');
572  $this->assertEquals($product->radioCstm->value , 'e');
573  $this->assertEquals($product->textCstm , 'This is a test Edit Text');
574  $this->assertEquals($product->textareaCstm , 'This is a test Edit TextArea');
575  $this->assertEquals($product->urlCstm , 'http://wwww.abc-edit.com');
576  $this->assertEquals($product->dateCstm , $dateAssert);
577  $this->assertEquals($product->datetimeCstm , $datetimeAssert);
578  $this->assertEquals($product->countrylistCstm->value , 'aaaa');
579  $this->assertEquals($product->statelistCstm->value , 'aaa1');
580  $this->assertEquals($product->citylistCstm->value , 'ab1');
581  $this->assertContains('gg' , $product->multiselectCstm->values);
582  $this->assertContains('hh' , $product->multiselectCstm->values);
583  $this->assertContains('reading' , $product->tagcloudCstm->values);
584  $this->assertContains('surfing' , $product->tagcloudCstm->values);
586  getByNameAndModelClassName('calcnumber', 'Product');
587  $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $product);
588  $this->assertEquals(132 , intval(str_replace(',', '', $testCalculatedValue))); // Not Coding Standard
589  }
590 
595  {
596  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
597 
598  //Retrieve the account id, the super user id and product Id.
599  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
600  $superUserId = $super->id;
601  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
602 
603  //Search a created Product using the customfields.
604  $this->resetPostArray();
605  $this->setGetArray(array(
606  'ProductsSearchForm' =>
608  $superUserId, $baseCurrency->id),
609  'ajax' => 'list-view')
610  );
611  //TODO Need to ask Jason
612  $content = $this->runControllerWithNoExceptionsAndGetContent('products/default');
613  $this->assertContains("myEditProduct", $content);
614  }
615 
620  {
621  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
622 
623  //Get the product id from the recently edited product.
624  $productId = self::getModelIdByModelNameAndName('Product', 'myEditProduct');
625 
626  //Set the product id so as to delete the product.
627  $this->setGetArray(array('id' => $productId));
628  $this->runControllerWithRedirectExceptionAndGetUrl('products/default/delete');
629 
630  //Check wether the product is deleted.
631  $product = Product::getByName('myEditProduct');
632  $this->assertEquals(0, count($product));
633  }
634 
639  {
640  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
641 
642  //Retrieve the account id, the super user id and product Id.
643  $accountId = self::getModelIdByModelNameAndName ('Account', 'superAccount');
644  $superUserId = $super->id;
645  $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
646 
647  //Search a created Product using the customfields.
648  $this->resetPostArray();
649  $this->setGetArray(array(
650  'ProductsSearchForm' =>
652  $superUserId, $baseCurrency->id),
653  'ajax' => 'list-view')
654  );
655  //TODO Need to ask Jason
656  $content = $this->runControllerWithNoExceptionsAndGetContent('products/default');
657 
658  //Assert that the edit Product does not exits after the search.
659  $this->assertContains("No results found", $content);
660  }
661 
666  {
667  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
668 
669  //Search a list item by typing in tag cloud attribute.
670  $this->resetPostArray();
671  $this->setGetArray(array('name' => 'tagcloud',
672  'term' => 'rea'));
673  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/autoCompleteCustomFieldData');
674 
675  //Check if the returned content contains the expected vlaue
676  $this->assertContains("reading", $content);
677  }
678 
683  {
684  Yii::app()->user->userModel = User::getByUsername('super');
685  $languageHelper = new ZurmoLanguageHelper();
686  $languageHelper->load();
687  $this->assertEquals('en', $languageHelper->getForCurrentUser());
688  Yii::app()->user->userModel->language = 'fr';
689  $this->assertTrue(Yii::app()->user->userModel->save());
690  $languageHelper->setActive('fr');
691  $this->assertEquals('fr', Yii::app()->user->getState('language'));
692 
693  $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
694 
695  //Search a list item by typing in tag cloud attribute.
696  $this->resetPostArray();
697  $this->setGetArray(array('name' => 'tagcloud',
698  'term' => 'surf'));
699  $content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/autoCompleteCustomFieldData');
700 
701  //Check if the returned content contains the expected vlaue
702  $this->assertContains("surfing fr", $content);
703  }
704  }
705 ?>
static makeBySecurableItem(SecurableItem $securableItem)
static calculateByFormulaAndModelAndResolveFormat($formula, RedBeanModel $model)
static getByUsername($username)
Definition: User.php:49
static getByCode($code)
Definition: Currency.php:90
static fetchProductsSearchFormGetData($accountId, $superUserId, $currencyId)
static getByName($name)
Definition: Product.php:45
static getById($id, $modelClassName=null)
logoutCurrentUserLoginNewUserAndGetByUsername($username)
runControllerWithNoExceptionsAndGetContent($route, $empty=false)
static getByNameAndModelClassName($name, $modelClassName)
Generated on Fri Jul 3 2020 07:10:34
Account Suspended
Account Suspended
This Account has been suspended.
Contact your hosting provider for more information.