Esempio n. 1
0
 public function testGetLocaleFormats()
 {
     $language = Yii::app()->getLanguage();
     $this->assertEquals($language, 'en');
     $this->assertEquals('M/d/yy h:mm a', DateTimeUtil::getLocaleDateTimeFormat());
     $this->assertEquals('M/d/yy', DateTimeUtil::getLocaleDateFormat());
     $this->assertEquals('h:mm a', DateTimeUtil::getLocaleTimeFormat());
     Yii::app()->setLanguage('de');
     $this->assertEquals('dd.MM.yy HH:mm', DateTimeUtil::getLocaleDateTimeFormat());
     $this->assertEquals('dd.MM.yy', DateTimeUtil::getLocaleDateFormat());
     $this->assertEquals('HH:mm', DateTimeUtil::getLocaleTimeFormat());
 }
 /**
  * @depends testEditOfTheNoteForTheTagCloudFieldAfterRemovingAllTagsPlacedForNotesModule
  */
 public function testEditOfTheNoteForTheCustomFieldsPlacedForNotesModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Set the date and datetime variable values here.
     $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormat(), time());
     $dateAssert = date('Y-m-d');
     $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormat(), time());
     $datetimeAssert = date('Y-m-d H:i:') . "00";
     //Get the super user, account, opportunity and contact id.
     $superUserId = $super->id;
     $superAccount = Account::getByName('superAccount');
     $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact2 superContact2son');
     $superOpportunityId = self::getModelIdByModelNameAndName('Opportunity', 'superOpp');
     $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
     //Retrieve the note Id based on the created note.
     $note = Note::getByName('Note Edit Description');
     //Edit a note based on the custom fields.
     $this->setGetArray(array('id' => $note[0]->id));
     $this->setPostArray(array('Note' => array('occurredOnDateTime' => $datetime, 'description' => 'Note Edit Description', 'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission), 'owner' => array('id' => $superUserId), 'checkboxCstm' => '0', 'currencyCstm' => array('value' => 40, 'currency' => array('id' => $baseCurrency->id)), 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'decimalCstm' => '12', 'picklistCstm' => array('value' => 'b'), 'multiselectCstm' => array('values' => array('gg', 'hh')), 'tagcloudCstm' => array('values' => array('reading', 'surfing')), 'countrylistCstm' => array('value' => 'aaaa'), 'statelistCstm' => array('value' => 'aaa1'), 'citylistCstm' => array('value' => 'ab1'), 'integerCstm' => '11', 'phoneCstm' => '259-784-2069', 'radioCstm' => array('value' => 'e'), 'textCstm' => 'This is a test Edit Text', 'textareaCstm' => 'This is a test Edit TextArea', 'urlCstm' => 'http://wwww.abc-edit.com'), 'ActivityItemForm' => array('Account' => array('id' => $superAccount[0]->id), 'Contact' => array('id' => $superContactId), 'Opportunity' => array('id' => $superOpportunityId))));
     $this->runControllerWithRedirectExceptionAndGetUrl('notes/default/edit');
     //Check the details if they are saved properly for the custom fields.
     $note = Note::getByName('Note Edit Description');
     //Retrieve the permission of the note.
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Note::getById($note[0]->id));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals($note[0]->description, 'Note Edit Description');
     $this->assertEquals($note[0]->occurredOnDateTime, $datetimeAssert);
     $this->assertEquals($note[0]->owner->id, $superUserId);
     $this->assertEquals($note[0]->activityItems->count(), 3);
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($note[0]->checkboxCstm, '0');
     $this->assertEquals($note[0]->currencyCstm->value, 40);
     $this->assertEquals($note[0]->currencyCstm->currency->id, $baseCurrency->id);
     $this->assertEquals($note[0]->dateCstm, $dateAssert);
     $this->assertEquals($note[0]->datetimeCstm, $datetimeAssert);
     $this->assertEquals($note[0]->decimalCstm, '12');
     $this->assertEquals($note[0]->picklistCstm->value, 'b');
     $this->assertEquals($note[0]->integerCstm, 11);
     $this->assertEquals($note[0]->phoneCstm, '259-784-2069');
     $this->assertEquals($note[0]->radioCstm->value, 'e');
     $this->assertEquals($note[0]->textCstm, 'This is a test Edit Text');
     $this->assertEquals($note[0]->textareaCstm, 'This is a test Edit TextArea');
     $this->assertEquals($note[0]->urlCstm, 'http://wwww.abc-edit.com');
     $this->assertEquals($note[0]->countrylistCstm->value, 'aaaa');
     $this->assertEquals($note[0]->statelistCstm->value, 'aaa1');
     $this->assertEquals($note[0]->citylistCstm->value, 'ab1');
     $this->assertContains('gg', $note[0]->multiselectCstm->values);
     $this->assertContains('hh', $note[0]->multiselectCstm->values);
     $this->assertContains('reading', $note[0]->tagcloudCstm->values);
     $this->assertContains('surfing', $note[0]->tagcloudCstm->values);
     $metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('calcnumber', 'Note');
     $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $note[0]);
     $this->assertEquals(23, $testCalculatedValue);
 }
 /**
  * @depends testEditOfTheContactForTheTagCloudFieldAfterRemovingAllTagsPlacedForContactsModule
  */
 public function testEditOfTheContactForTheCustomFieldsPlacedForContactsModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Set the date and datetime variable values here.
     $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormat(), time());
     $dateAssert = date('Y-m-d');
     $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormat(), time());
     $datetimeAssert = date('Y-m-d H:i:') . "00";
     $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
     //Retrieve the super account id and the super user id.
     $accountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
     $superUserId = $super->id;
     //Retrieve the contact id.
     $contact = Contact::getByName('Sarah Williams Edit');
     $contactId = $contact[0]->id;
     //Retrieve the Contact State (Status) Id based on the name.
     $contactState = ContactState::getByName('RecycledC');
     $contactStateId = $contactState[0]->id;
     //Edit and save the contact.
     $this->setGetArray(array('id' => $contactId));
     $this->setPostArray(array('Contact' => array('title' => array('value' => 'Mrs.'), 'firstName' => 'Sarah', 'lastName' => 'Williams Edit', 'jobTitle' => 'Sales Director Edit', 'department' => 'Sales Edit', 'officePhone' => '739-742-3005', 'source' => array('value' => 'Inbound Call'), 'mobilePhone' => '285-300-8232', 'officeFax' => '255-454-1914', 'state' => array('id' => $contactStateId), 'owner' => array('id' => $superUserId), 'account' => array('id' => $accountId), 'primaryEmail' => array('emailAddress' => '*****@*****.**', 'optOut' => '0', 'isInvalid' => '0'), 'secondaryEmail' => array('emailAddress' => '*****@*****.**', 'optOut' => '0', 'isInvalid' => '0'), 'primaryAddress' => array('street1' => '26378 South Arlington Ave', 'street2' => '', 'city' => 'San Jose', 'state' => 'CA', 'postalCode' => '95131', 'country' => 'USA'), 'secondaryAddress' => array('street1' => '18693 West Spring Center', 'street2' => '', 'city' => 'Philadelphia', 'state' => 'PA', 'postalCode' => '19102', 'country' => 'USA'), 'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission), 'description' => 'This is a Edit Description', 'checkboxCstm' => '0', 'currencyCstm' => array('value' => 40, 'currency' => array('id' => $baseCurrency->id)), 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'decimalCstm' => '12', 'picklistCstm' => array('value' => 'b'), 'multiselectCstm' => array('values' => array('gg', 'hh')), 'tagcloudCstm' => array('values' => array('reading', 'surfing')), 'countrylistCstm' => array('value' => 'aaaa'), 'statelistCstm' => array('value' => 'aaa1'), 'citylistCstm' => array('value' => 'ab1'), 'integerCstm' => '11', 'phoneCstm' => '259-784-2069', 'radioCstm' => array('value' => 'e'), 'textCstm' => 'This is a test Edit Text', 'textareaCstm' => 'This is a test Edit TextArea', 'urlCstm' => 'http://wwww.abc-edit.com'), 'save' => 'Save'));
     $this->runControllerWithRedirectExceptionAndGetUrl('contacts/default/edit');
     //Check the details if they are saved properly for the custom fields after the edit.
     $contact = Contact::getById($contactId);
     //Retrieve the permission of the contact.
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($contact);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals($contact->title->value, 'Mrs.');
     $this->assertEquals($contact->firstName, 'Sarah');
     $this->assertEquals($contact->lastName, 'Williams Edit');
     $this->assertEquals($contact->state->id, $contactStateId);
     $this->assertEquals($contact->jobTitle, 'Sales Director Edit');
     $this->assertEquals($contact->department, 'Sales Edit');
     $this->assertEquals($contact->officePhone, '739-742-3005');
     $this->assertEquals($contact->source->value, 'Inbound Call');
     $this->assertEquals($contact->mobilePhone, '285-300-8232');
     $this->assertEquals($contact->officeFax, '255-454-1914');
     $this->assertEquals($contact->primaryEmail->emailAddress, '*****@*****.**');
     $this->assertEquals($contact->primaryEmail->optOut, '0');
     $this->assertEquals($contact->primaryEmail->isInvalid, '0');
     $this->assertEquals($contact->secondaryEmail->emailAddress, '*****@*****.**');
     $this->assertEquals($contact->secondaryEmail->optOut, '0');
     $this->assertEquals($contact->secondaryEmail->isInvalid, '0');
     $this->assertEquals($contact->primaryAddress->street1, '26378 South Arlington Ave');
     $this->assertEquals($contact->primaryAddress->street2, '');
     $this->assertEquals($contact->primaryAddress->city, 'San Jose');
     $this->assertEquals($contact->primaryAddress->state, 'CA');
     $this->assertEquals($contact->primaryAddress->postalCode, '95131');
     $this->assertEquals($contact->primaryAddress->country, 'USA');
     $this->assertEquals($contact->secondaryAddress->street1, '18693 West Spring Center');
     $this->assertEquals($contact->secondaryAddress->street2, '');
     $this->assertEquals($contact->secondaryAddress->city, 'Philadelphia');
     $this->assertEquals($contact->secondaryAddress->state, 'PA');
     $this->assertEquals($contact->secondaryAddress->postalCode, '19102');
     $this->assertEquals($contact->secondaryAddress->country, 'USA');
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($contact->description, 'This is a Edit Description');
     $this->assertEquals($contact->checkboxCstm, '0');
     $this->assertEquals($contact->currencyCstm->value, 40);
     $this->assertEquals($contact->currencyCstm->currency->id, $baseCurrency->id);
     $this->assertEquals($contact->dateCstm, $dateAssert);
     $this->assertEquals($contact->datetimeCstm, $datetimeAssert);
     $this->assertEquals($contact->decimalCstm, '12');
     $this->assertEquals($contact->picklistCstm->value, 'b');
     $this->assertEquals($contact->integerCstm, 11);
     $this->assertEquals($contact->phoneCstm, '259-784-2069');
     $this->assertEquals($contact->radioCstm->value, 'e');
     $this->assertEquals($contact->textCstm, 'This is a test Edit Text');
     $this->assertEquals($contact->textareaCstm, 'This is a test Edit TextArea');
     $this->assertEquals($contact->urlCstm, 'http://wwww.abc-edit.com');
     $this->assertEquals($contact->countrylistCstm->value, 'aaaa');
     $this->assertEquals($contact->statelistCstm->value, 'aaa1');
     $this->assertEquals($contact->citylistCstm->value, 'ab1');
     $this->assertContains('gg', $contact->multiselectCstm->values);
     $this->assertContains('hh', $contact->multiselectCstm->values);
     $this->assertContains('reading', $contact->tagcloudCstm->values);
     $this->assertContains('surfing', $contact->tagcloudCstm->values);
     $metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('calcnumber', 'Contact');
     $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $contact);
     $this->assertEquals(23, $testCalculatedValue);
 }
 /**
  * @depends testEditOfTheProductTemplateForTheTagCloudFieldAfterRemovingAllTagsPlacedForProductTemplatesModule
  */
 public function testEditOfTheProductTemplateForTheCustomFieldsPlacedForProductTemplatesModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Set the date and datetime variable values here.
     $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormat(), time());
     $dateAssert = date('Y-m-d');
     $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormat(), time());
     $datetimeAssert = date('Y-m-d H:i:') . "00";
     $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     //Retrieve the account id, the super user id and opportunity Id.
     $superUserId = $super->id;
     $productTemplate = ProductTemplate::getByName('myEditProductTemplate');
     $productTemplateId = $productTemplate[0]->id;
     //Edit a new ProductTemplate based on the custom fields.
     $this->setGetArray(array('id' => $productTemplateId));
     $this->setPostArray(array('ProductTemplate' => array('name' => 'myEditProductTemplate', 'type' => ProductTemplate::TYPE_PRODUCT, 'description' => 'Test Description', 'sellPrice' => array('currency' => array('id' => $baseCurrency->id), 'value' => 200), 'cost' => array('currency' => array('id' => $baseCurrency->id), 'value' => 200), 'listPrice' => array('currency' => array('id' => $baseCurrency->id), 'value' => 200), 'priceFrequency' => 2, 'status' => ProductTemplate::STATUS_ACTIVE, 'sellPriceFormula' => array('type' => SellPriceFormula::TYPE_EDITABLE), 'checkboxCstm' => '0', 'currencyCstm' => array('value' => 40, 'currency' => array('id' => $baseCurrency->id)), 'decimalCstm' => '12', 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'picklistCstm' => array('value' => 'b'), 'multiselectCstm' => array('values' => array('gg', 'hh')), 'tagcloudCstm' => array('values' => array('reading', 'surfing')), 'countrylistCstm' => array('value' => 'aaaa'), 'statelistCstm' => array('value' => 'aaa1'), 'citylistCstm' => array('value' => 'ab1'), 'integerCstm' => '11', 'phoneCstm' => '259-784-2069', 'radioCstm' => array('value' => 'e'), 'textCstm' => 'This is a test Edit Text', 'textareaCstm' => 'This is a test Edit TextArea', 'urlCstm' => 'http://wwww.abc-edit.com')));
     $this->runControllerWithRedirectExceptionAndGetUrl('productTemplates/default/edit');
     //Check the details if they are saved properly for the custom fields.
     $productTemplateId = self::getModelIdByModelNameAndName('ProductTemplate', 'myEditProductTemplate');
     $productTemplate = ProductTemplate::getById($productTemplateId);
     $this->assertEquals($productTemplate->name, 'myEditProductTemplate');
     $this->assertEquals($productTemplate->sellPrice->value, 200.0);
     $this->assertEquals($productTemplate->cost->value, 200.0);
     $this->assertEquals($productTemplate->listPrice->value, 200.0);
     $this->assertEquals($productTemplate->description, 'Test Description');
     $this->assertEquals($productTemplate->type, ProductTemplate::TYPE_PRODUCT);
     $this->assertEquals($productTemplate->status, ProductTemplate::STATUS_ACTIVE);
     $this->assertEquals($productTemplate->priceFrequency, 2);
     $this->assertEquals($productTemplate->sellPriceFormula->type, SellPriceFormula::TYPE_EDITABLE);
     $this->assertEquals($productTemplate->checkboxCstm, '0');
     $this->assertEquals($productTemplate->currencyCstm->value, 40);
     $this->assertEquals($productTemplate->currencyCstm->currency->id, $baseCurrency->id);
     $this->assertEquals($productTemplate->dateCstm, $dateAssert);
     $this->assertEquals($productTemplate->datetimeCstm, $datetimeAssert);
     $this->assertEquals($productTemplate->decimalCstm, '12');
     $this->assertEquals($productTemplate->picklistCstm->value, 'b');
     $this->assertEquals($productTemplate->integerCstm, 11);
     $this->assertEquals($productTemplate->phoneCstm, '259-784-2069');
     $this->assertEquals($productTemplate->radioCstm->value, 'e');
     $this->assertEquals($productTemplate->textCstm, 'This is a test Edit Text');
     $this->assertEquals($productTemplate->textareaCstm, 'This is a test Edit TextArea');
     $this->assertEquals($productTemplate->urlCstm, 'http://wwww.abc-edit.com');
     $this->assertEquals($productTemplate->dateCstm, $dateAssert);
     $this->assertEquals($productTemplate->datetimeCstm, $datetimeAssert);
     $this->assertEquals($productTemplate->countrylistCstm->value, 'aaaa');
     $this->assertEquals($productTemplate->statelistCstm->value, 'aaa1');
     $this->assertEquals($productTemplate->citylistCstm->value, 'ab1');
     $this->assertContains('gg', $productTemplate->multiselectCstm->values);
     $this->assertContains('hh', $productTemplate->multiselectCstm->values);
     $this->assertContains('reading', $productTemplate->tagcloudCstm->values);
     $this->assertContains('surfing', $productTemplate->tagcloudCstm->values);
     $metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('calcnumber', 'ProductTemplate');
     $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $productTemplate);
     $this->assertEquals(132, intval(str_replace(',', "", $testCalculatedValue)));
     // Not Coding Standard
 }
 /**
  * @depends testEditOfTheProductForTheTagCloudFieldAfterRemovingAllTagsPlacedForProductsModule
  */
 public function testEditOfTheProductForTheCustomFieldsPlacedForProductsModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Set the date and datetime variable values here.
     $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormat(), time());
     $dateAssert = date('Y-m-d');
     $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormat(), time());
     $datetimeAssert = date('Y-m-d H:i:') . "00";
     $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     //Retrieve the account id, the super user id and product Id.
     $accountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
     $superUserId = $super->id;
     $explicitReadWriteModelPermission = ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP;
     $product = Product::getByName('myEditProduct');
     $productId = $product[0]->id;
     //Edit a new Product based on the custom fields.
     $this->setGetArray(array('id' => $productId));
     $this->setPostArray(array('Product' => array('name' => 'myEditProduct', 'owner' => array('id' => $superUserId), 'type' => 1, 'sellPrice' => array('currency' => array('id' => $baseCurrency->id), 'value' => 200), 'account' => array('id' => $accountId), 'quantity' => 10, 'priceFrequency' => 2, 'stage' => array('value' => 'Open'), 'explicitReadWriteModelPermissions' => array('type' => $explicitReadWriteModelPermission), 'checkboxCstm' => '0', 'currencyCstm' => array('value' => 40, 'currency' => array('id' => $baseCurrency->id)), 'decimalCstm' => '12', 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'picklistCstm' => array('value' => 'b'), 'multiselectCstm' => array('values' => array('gg', 'hh')), 'tagcloudCstm' => array('values' => array('reading', 'surfing')), 'countrylistCstm' => array('value' => 'aaaa'), 'statelistCstm' => array('value' => 'aaa1'), 'citylistCstm' => array('value' => 'ab1'), 'integerCstm' => '11', 'phoneCstm' => '259-784-2069', 'radioCstm' => array('value' => 'e'), 'textCstm' => 'This is a test Edit Text', 'textareaCstm' => 'This is a test Edit TextArea', 'urlCstm' => 'http://wwww.abc-edit.com')));
     $this->runControllerWithRedirectExceptionAndGetUrl('products/default/edit');
     //Check the details if they are saved properly for the custom fields.
     $productId = self::getModelIdByModelNameAndName('Product', 'myEditProduct');
     $product = Product::getById($productId);
     //Retrieve the permission of the product.
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($product);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals($product->name, 'myEditProduct');
     $this->assertEquals($product->quantity, 10);
     $this->assertEquals($product->sellPrice->value, 200.0);
     $this->assertEquals($product->account->id, $accountId);
     $this->assertEquals($product->type, 1);
     $this->assertEquals($product->stage->value, 'Open');
     $this->assertEquals($product->owner->id, $superUserId);
     $this->assertEquals(1, count($readWritePermitables));
     $this->assertEquals(0, count($readOnlyPermitables));
     $this->assertEquals($product->checkboxCstm, '0');
     $this->assertEquals($product->currencyCstm->value, 40);
     $this->assertEquals($product->currencyCstm->currency->id, $baseCurrency->id);
     $this->assertEquals($product->dateCstm, $dateAssert);
     $this->assertEquals($product->datetimeCstm, $datetimeAssert);
     $this->assertEquals($product->decimalCstm, '12');
     $this->assertEquals($product->picklistCstm->value, 'b');
     $this->assertEquals($product->integerCstm, 11);
     $this->assertEquals($product->phoneCstm, '259-784-2069');
     $this->assertEquals($product->radioCstm->value, 'e');
     $this->assertEquals($product->textCstm, 'This is a test Edit Text');
     $this->assertEquals($product->textareaCstm, 'This is a test Edit TextArea');
     $this->assertEquals($product->urlCstm, 'http://wwww.abc-edit.com');
     $this->assertEquals($product->dateCstm, $dateAssert);
     $this->assertEquals($product->datetimeCstm, $datetimeAssert);
     $this->assertEquals($product->countrylistCstm->value, 'aaaa');
     $this->assertEquals($product->statelistCstm->value, 'aaa1');
     $this->assertEquals($product->citylistCstm->value, 'ab1');
     $this->assertContains('gg', $product->multiselectCstm->values);
     $this->assertContains('hh', $product->multiselectCstm->values);
     $this->assertContains('reading', $product->tagcloudCstm->values);
     $this->assertContains('surfing', $product->tagcloudCstm->values);
     $metadata = CalculatedDerivedAttributeMetadata::getByNameAndModelClassName('calcnumber', 'Product');
     $testCalculatedValue = CalculatedNumberUtil::calculateByFormulaAndModelAndResolveFormat($metadata->getFormula(), $product);
     $this->assertEquals(132, intval(str_replace(',', '', $testCalculatedValue)));
     // Not Coding Standard
 }
 /**
  * @depends testCreateSecondAccountForUserAfterTheCustomFieldsArePlacedForAccountsModule
  */
 public function testMultiValueCustomFieldContentAfterCreateAndEditPlacedForAccountsModule()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Set the date and datetime variable values here
     $date = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateFormat(), time());
     $dateAssert = date('Y-m-d');
     $datetime = Yii::app()->dateFormatter->format(DateTimeUtil::getLocaleDateTimeFormat(), time());
     $datetimeAssert = date('Y-m-d H:i:') . "00";
     $baseCurrency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     //Create a new account based on the custom fields.
     $this->resetGetArray();
     $this->setPostArray(array('Account' => array('name' => 'myThirdAccount', 'officePhone' => '259-784-2169', 'industry' => array('value' => 'Automotive'), 'officeFax' => '299-845-7863', 'employees' => '930', 'annualRevenue' => '474000000', 'type' => array('value' => 'Prospect'), 'website' => 'http://www.Unnamed.com', 'primaryEmail' => array('emailAddress' => '*****@*****.**', 'optOut' => '1', 'isInvalid' => '0'), 'secondaryEmail' => array('emailAddress' => '', 'optOut' => '0', 'isInvalid' => '0'), 'billingAddress' => array('street1' => '6466 South Madison Creek', 'street2' => '', 'city' => 'Chicago', 'state' => 'IL', 'postalCode' => '60652', 'country' => 'USA'), 'shippingAddress' => array('street1' => '27054 West Michigan Lane', 'street2' => '', 'city' => 'Austin', 'state' => 'TX', 'postalCode' => '78759', 'country' => 'USA'), 'description' => 'This is a Description', 'explicitReadWriteModelPermissions' => array('type' => null), 'checkboxCstm' => '1', 'currencyCstm' => array('value' => 45, 'currency' => array('id' => $baseCurrency->id)), 'dateCstm' => $date, 'datetimeCstm' => $datetime, 'decimalCstm' => '123', 'picklistCstm' => array('value' => 'a'), 'multiselectCstm' => array('values' => array('gg', 'ff')), 'tagcloudCstm' => array('values' => array('reading', 'writing')), 'countrylistCstm' => array('value' => 'bbbb'), 'statelistCstm' => array('value' => 'bbb1'), 'citylistCstm' => array('value' => 'bb1'), 'integerCstm' => '12', 'phoneCstm' => '259-784-2169', 'radioCstm' => array('value' => 'd'), 'textCstm' => 'This is a test Text', 'textareaCstm' => 'This is a test TextArea', 'urlCstm' => 'http://wwww.abc.com')));
     $this->runControllerWithRedirectExceptionAndGetUrl('accounts/default/create');
     //Check the details if they are saved properly for the custom fields.
     $account = Account::getByName('myThirdAccount');
     //Retrieve the permission for the account.
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Account::getById($account[0]->id));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals(1, count($account));
     $this->assertEquals($account[0]->name, 'myThirdAccount');
     $this->assertEquals(2, $account[0]->multiselectCstm->values->count());
     $this->assertEquals(2, $account[0]->tagcloudCstm->values->count());
     $this->assertContains('gg', $account[0]->multiselectCstm->values);
     $this->assertContains('ff', $account[0]->multiselectCstm->values);
     $this->assertContains('reading', $account[0]->tagcloudCstm->values);
     $this->assertContains('writing', $account[0]->tagcloudCstm->values);
     unset($account);
     $account = Account::getByName('myThirdAccount');
     $accountId = $account[0]->id;
     //Edit and save the account.
     $this->setGetArray(array('id' => $accountId));
     $this->setPostArray(array('Account' => array('name' => 'myThirdAccount', 'multiselectCstm' => array('values' => array('ff')), 'tagcloudCstm' => array('values' => array('writing'))), 'save' => 'Save'));
     $this->runControllerWithRedirectExceptionAndGetUrl('accounts/default/edit');
     //Check the details if they are saved properly for the custom fields.
     $account = Account::getByName('myThirdAccount');
     //Retrieve the permission for the account.
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem(Account::getById($account[0]->id));
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $readOnlyPermitables = $explicitReadWriteModelPermissions->getReadOnlyPermitables();
     $this->assertEquals(1, count($account));
     $this->assertEquals(1, $account[0]->multiselectCstm->values->count());
     $this->assertContains('ff', $account[0]->multiselectCstm->values);
     $this->assertNotContains('gg', $account[0]->multiselectCstm->values);
     $this->assertNotContains('hh', $account[0]->multiselectCstm->values);
     $this->assertNotContains('rr', $account[0]->multiselectCstm->values);
     $this->assertEquals(1, $account[0]->tagcloudCstm->values->count());
     $this->assertContains('writing', $account[0]->tagcloudCstm->values);
 }