本文整理汇总了PHP中ContactState::getByName方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactState::getByName方法的具体用法?PHP ContactState::getByName怎么用?PHP ContactState::getByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContactState
的用法示例。
在下文中一共展示了ContactState::getByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sanitizeValue
/**
* Given a contact state id, attempt to get and return a contact state object. If the id is invalid, then an
* InvalidValueToSanitizeException will be thrown.
* @param mixed $value
* @return sanitized value
* @throws InvalidValueToSanitizeException
* @throws NotFoundException
*/
public function sanitizeValue($value)
{
assert('$this->attributeName == null');
if ($value == null) {
return $value;
}
try {
if ((int) $value <= 0) {
$states = ContactState::getByName($value);
if (count($states) > 1) {
throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'Status specified is not unique and is invalid.'));
} elseif (count($states) == 0) {
throw new NotFoundException();
}
$state = $states[0];
} else {
$state = ContactState::getById($value);
}
$startingState = ContactsUtil::getStartingState();
if (!static::resolvesValidStateByOrder($state->order, $startingState->order)) {
throw new InvalidValueToSanitizeException(Zurmo::t('ZurmoModule', 'Status specified is invalid.'));
}
return $state;
} catch (NotFoundException $e) {
throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'Status specified does not exist.'));
}
}
示例2: testGetExportValue
public function testGetExportValue()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$data = array();
$contactStates = ContactState::getByName('Qualified');
$contact = new Contact();
$contact->owner = $super;
$contact->firstName = 'Super';
$contact->lastName = 'Man';
$contact->jobTitle = 'Superhero';
$contact->description = 'Some Description';
$contact->department = 'Red Tape';
$contact->officePhone = '1234567890';
$contact->mobilePhone = '0987654321';
$contact->officeFax = '1222222222';
$contact->state = $contactStates[0];
$this->assertTrue($contact->save());
$adapter = new ContactStateRedBeanModelAttributeValueToExportValueAdapter($contact, 'state');
$adapter->resolveData($data);
$compareData = array($contactStates[0]->name);
$this->assertEquals($compareData, $data);
$data = array();
$adapter->resolveHeaderData($data);
$compareData = array($contact->getAttributeLabel('state'));
$this->assertEquals($compareData, $data);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:27,代码来源:ContactStateRedBeanModelAttributeValueToExportValueAdapterTest.php
示例3: testCreateAndGetContactWebFormById
public function testCreateAndGetContactWebFormById()
{
$allAttributes = ContactWebFormsUtil::getAllAttributes();
$placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
$contactFormAttributes = ContactWebFormsUtil::getAllPlacedAttributes($allAttributes, $placedAttributes);
$attributes = array_keys($contactFormAttributes);
$this->assertTrue(ContactsModule::loadStartingData());
$contactStates = ContactState::getByName('New');
$contactWebForm = new ContactWebForm();
$contactWebForm->name = 'Test Form';
$contactWebForm->redirectUrl = 'http://google.com';
$contactWebForm->submitButtonLabel = 'Save';
$contactWebForm->defaultState = $contactStates[0];
$contactWebForm->serializedData = serialize($attributes);
$contactWebForm->defaultOwner = Yii::app()->user->userModel;
$this->assertTrue($contactWebForm->save());
$id = $contactWebForm->id;
unset($contactWebForm);
$contactWebForm = ContactWebForm::getById($id);
$this->assertEquals('Test Form', $contactWebForm->name);
$this->assertEquals('http://google.com', $contactWebForm->redirectUrl);
$this->assertEquals('Save', $contactWebForm->submitButtonLabel);
$this->assertEquals('New', $contactWebForm->defaultState->name);
$this->assertEquals($attributes, unserialize($contactWebForm->serializedData));
}
示例4: testCreateAndGetContactWebFormEntryById
public function testCreateAndGetContactWebFormEntryById()
{
$allAttributes = ContactWebFormsUtil::getAllAttributes();
$placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
$contactFormAttributes = ContactWebFormsUtil::getAllPlacedAttributes($allAttributes, $placedAttributes);
$attributes = array_keys($contactFormAttributes);
$this->assertTrue(ContactsModule::loadStartingData());
$contactStates = ContactState::getByName('New');
$contactWebForm = new ContactWebForm();
$contactWebForm->name = 'Test Form';
$contactWebForm->redirectUrl = 'http://google.com';
$contactWebForm->submitButtonLabel = 'Save';
$contactWebForm->defaultState = $contactStates[0];
$contactWebForm->defaultOwner = Yii::app()->user->userModel;
$contactWebForm->serializedData = serialize($attributes);
$contactWebForm->save();
$contact = new Contact();
$contact->owner = $contactWebForm->defaultOwner;
$contact->state = $contactWebForm->defaultState;
$contact->firstName = 'Super';
$contact->lastName = 'Man';
$contact->jobTitle = 'Superhero';
$contact->companyName = 'Test Inc.';
if ($contact->validate()) {
$contactWebFormEntryStatus = ContactWebFormEntry::STATUS_SUCCESS;
$contactWebFormEntryMessage = ContactWebFormEntry::STATUS_SUCCESS_MESSAGE;
} else {
$contactWebFormEntryStatus = ContactWebFormEntry::STATUS_ERROR;
$contactWebFormEntryMessage = ContactWebFormEntry::STATUS_ERROR_MESSAGE;
}
$contact->save();
foreach ($contactFormAttributes as $attributeName => $attributeValue) {
$contactFormAttributes[$attributeName] = $contact->{$attributeName};
}
$contactFormAttributes['owner'] = $contactWebForm->defaultOwner->id;
$contactFormAttributes['state'] = $contactWebForm->defaultState->id;
$contactWebFormEntry = new ContactWebFormEntry();
$contactWebFormEntry->serializedData = serialize($contactFormAttributes);
$contactWebFormEntry->status = $contactWebFormEntryStatus;
$contactWebFormEntry->message = $contactWebFormEntryMessage;
$contactWebFormEntry->contactWebForm = $contactWebForm;
$contactWebFormEntry->contact = $contact;
$this->assertTrue($contactWebFormEntry->save());
$contactWebFormEntryId = $contactWebFormEntry->id;
unset($contactWebFormEntry);
$contactWebFormEntry = ContactWebFormEntry::getById($contactWebFormEntryId);
$this->assertEquals('Test Form', $contactWebFormEntry->contactWebForm->name);
$this->assertEquals('Super', $contactWebFormEntry->contact->firstName);
$this->assertEquals('Man', $contactWebFormEntry->contact->lastName);
$contactFormAttributes = unserialize($contactWebFormEntry->serializedData);
$this->assertEquals('Super', $contactFormAttributes['firstName']);
$this->assertEquals('Man', $contactFormAttributes['lastName']);
$this->assertEquals('Superhero', $contactFormAttributes['jobTitle']);
$this->assertEquals('Test Inc.', $contactFormAttributes['companyName']);
}
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$loaded = ContactsModule::loadStartingData();
assert($loaded);
// Not Coding Standard
$contactStates = ContactState::getByName('New');
self::$newState = $contactStates[0];
$contactStates = ContactState::getByName('In progress');
self::$inProgressState = $contactStates[0];
$contactStates = ContactState::getByName('Recycled');
self::$recycledState = $contactStates[0];
$contactStates = ContactState::getByName('Dead');
self::$deadState = $contactStates[0];
$contactStates = ContactState::getByName('Qualified');
self::$qualifiedState = $contactStates[0];
$contactStates = ContactState::getByName('Customer');
self::$customerState = $contactStates[0];
}
示例6: createContactWebFormByName
public static function createContactWebFormByName($name, $owner = null)
{
if ($owner === null) {
$owner = Yii::app()->user->userModel;
}
$placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
ContactsModule::loadStartingData();
$contactStates = ContactState::getByName('New');
$contactWebForm = new ContactWebForm();
$contactWebForm->name = $name;
$contactWebForm->redirectUrl = 'http://www.zurmo.com/';
$contactWebForm->submitButtonLabel = 'Save';
$contactWebForm->defaultState = $contactStates[0];
$contactWebForm->serializedData = serialize($placedAttributes);
$contactWebForm->defaultOwner = $owner;
$saved = $contactWebForm->save();
assert('$saved');
return $contactWebForm;
}
示例7: testCreateAndGetContactWebFormById
public function testCreateAndGetContactWebFormById()
{
ContactWebFormTestHelper::deleteAllContactWebForms();
$placedAttributes = array('firstName', 'lastName', 'companyName', 'jobTitle');
$this->assertTrue(ContactsModule::loadStartingData());
$contactStates = ContactState::getByName('New');
$contactWebForm = new ContactWebForm();
$contactWebForm->name = 'Test Form';
$contactWebForm->redirectUrl = 'http://zurmo.com';
$contactWebForm->submitButtonLabel = 'Save';
$contactWebForm->defaultState = $contactStates[0];
$contactWebForm->serializedData = serialize($placedAttributes);
$contactWebForm->defaultOwner = Yii::app()->user->userModel;
$this->assertTrue($contactWebForm->save());
$id = $contactWebForm->id;
unset($contactWebForm);
$contactWebForm = ContactWebForm::getById($id);
$this->assertEquals('Test Form', $contactWebForm->name);
$this->assertEquals('http://zurmo.com', $contactWebForm->redirectUrl);
$this->assertEquals('Save', $contactWebForm->submitButtonLabel);
$this->assertEquals('New', $contactWebForm->defaultState->name);
$this->assertEquals($placedAttributes, unserialize($contactWebForm->serializedData));
$this->assertNull($contactWebForm->defaultPermissionSetting);
$this->assertNull($contactWebForm->defaultPermissionGroupSetting);
$contactWebForm->name = 'New Test Form';
$contactWebForm->redirectUrl = 'http://zurmo.org';
$contactWebForm->submitButtonLabel = 'Save and Redirect';
$contactWebForm->defaultPermissionSetting = UserConfigurationForm::DEFAULT_PERMISSIONS_SETTING_EVERYONE;
$this->assertTrue($contactWebForm->save());
$id = $contactWebForm->id;
unset($contactWebForm);
$contactWebForm = ContactWebForm::getById($id);
$this->assertEquals('New Test Form', $contactWebForm->name);
$this->assertEquals('http://zurmo.org', $contactWebForm->redirectUrl);
$this->assertEquals('Save and Redirect', $contactWebForm->submitButtonLabel);
$this->assertEquals($contactWebForm->defaultPermissionSetting, UserConfigurationForm::DEFAULT_PERMISSIONS_SETTING_EVERYONE);
$this->assertNull($contactWebForm->defaultPermissionGroupSetting);
}
示例8: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = User::getByUsername('super');
$bobby = UserTestHelper::createBasicUser('bobby');
$sarah = UserTestHelper::createBasicUser('sarah');
self::$superUserId = $super->id;
self::$bobbyUserId = $bobby->id;
self::$sarahUserId = $sarah->id;
$currency = Currency::makeBaseCurrency();
assert($currency->code == 'USD');
// Not Coding Standard
self::$baseCurrencyId = $currency->id;
$currency = new Currency();
$currency->code = 'EUR';
$currency->rateToBase = 2;
assert($currency->save());
// Not Coding Standard
self::$eurCurrencyId = $currency->id;
$values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
$fieldData = CustomFieldData::getByName('WorkflowTestDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('A1', 'B2', 'C3', 'D4', 'E5', 'F6');
$fieldData = CustomFieldData::getByName('WorkflowTestRadioDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
$fieldData = CustomFieldData::getByName('WorkflowTestMultiDropDown');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$values = array('M1', 'M2', 'M3', 'M4', 'M5', 'M6');
$fieldData = CustomFieldData::getByName('WorkflowTestTagCloud');
$fieldData->serializedData = serialize($values);
$saved = $fieldData->save();
assert($saved);
// Not Coding Standard
$loaded = ContactsModule::loadStartingData();
assert($loaded);
// Not Coding Standard
$contactStates = ContactState::getByName('New');
self::$newState = $contactStates[0];
$contactStates = ContactState::getByName('In progress');
self::$inProgressState = $contactStates[0];
self::$groupTest = new Group();
self::$groupTest->name = 'test';
$saved = self::$groupTest->save();
assert($saved);
// Not Coding Standard
$group = Group::getByName(Group::EVERYONE_GROUP_NAME);
$saved = $group->save();
assert($saved);
// Not Coding Standard
}
示例9: testWhetherSearchWorksForTheCustomFieldsPlacedForLeadsModuleAfterDeletingTheLead
/**
* @depends testDeleteOfTheLeadUserForTheCustomFieldsPlacedForLeadsModule
*/
public function testWhetherSearchWorksForTheCustomFieldsPlacedForLeadsModuleAfterDeletingTheLead()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Retrieve the super user id.
$superUserId = $super->id;
//Retrieve the Lead State (Status) Id based on the name.
$leadState = ContactState::getByName('In Progress');
$leadStateId = $leadState[0]->id;
//Search a created lead using the customfields.
$this->resetPostArray();
$this->setGetArray(array('LeadsSearchForm' => LeadsDesignerWalkthroughHelperUtil::fetchLeadsSearchFormGetData($leadStateId, $superUserId), 'ajax' => 'list-view'));
$content = $this->runControllerWithNoExceptionsAndGetContent('leads/default');
//Assert that the edit lead does not exits after the search.
$this->assertContains("No results found", $content);
$this->assertNotContains("26378 South Arlington Ave", $content);
}
示例10: testResolvePersonOrAccountByEmailAddress
public function testResolvePersonOrAccountByEmailAddress()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$user = UserTestHelper::createBasicUser('joseph');
$anotherUser = UserTestHelper::createBasicUser('josephine');
$emailAddress = 'sameone234@example.com';
// There are no users in system with the email.
Yii::app()->user->userModel = $user;
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, false, false, false);
$this->assertNull($personOrAccount);
// There is user is system with the email.
Yii::app()->user->userModel = $super;
$anotherUser->primaryEmail->emailAddress = $emailAddress;
$this->assertTrue($anotherUser->save());
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, false, false, false);
$this->assertEquals($anotherUser->id, $personOrAccount->id);
$this->assertTrue($personOrAccount instanceof User);
// Now test email with accounts.
// User can access accounts, but there are no accounts in system with the email.
$anotherUser->primaryEmail->emailAddress = 'sample45@example.com';
$this->assertTrue($anotherUser->save());
Yii::app()->user->userModel = $user;
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, false, false, true);
$this->assertNull($personOrAccount);
// User can access accounts, but there are no accounts in system with the email.
// But there is user is system with the email
Yii::app()->user->userModel = $super;
$anotherUser->primaryEmail->emailAddress = $emailAddress;
$this->assertTrue($anotherUser->save());
Yii::app()->user->userModel = $user;
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, false, false, true);
$this->assertEquals($anotherUser->id, $personOrAccount->id);
$this->assertTrue($personOrAccount instanceof User);
// User can access accounts, and there is account in system with the email.
// But owner of email is super users, so it shouldn't return account
Yii::app()->user->userModel = $super;
$anotherUser->primaryEmail->emailAddress = 'sample45@example.com';
$this->assertTrue($anotherUser->save());
Yii::app()->user->userModel = $super;
$email = new Email();
$email->emailAddress = $emailAddress;
$email2 = new Email();
$email2->emailAddress = 'aabb@example.com';
$account = new Account();
$account->owner = $super;
$account->name = 'Test Account';
$account->primaryEmail = $email;
$account->secondaryEmail = $email2;
$this->assertTrue($account->save());
Yii::app()->user->userModel = $user;
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, false, false, true);
$this->assertNull($personOrAccount);
Yii::app()->user->userModel = $super;
$account->owner = $user;
$this->assertTrue($account->save());
Yii::app()->user->userModel = $user;
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, false, false, true);
$this->assertEquals($account->id, $personOrAccount->id);
$this->assertTrue($personOrAccount instanceof Account);
// Now test with contacts/leads. Please note that we are not removing email address
// from users and accounts, so if contact or lead exist with this email, they should be returned
Yii::app()->user->userModel = $user;
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, true, true, false);
$this->assertNull($personOrAccount);
// User can access contacts, but there are no contact in system with the email.
// But there is user and account is system with the email
Yii::app()->user->userModel = $super;
$anotherUser->primaryEmail->emailAddress = $emailAddress;
$this->assertTrue($anotherUser->save());
Yii::app()->user->userModel = $user;
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, false, false, true);
$this->assertEquals($account->id, $personOrAccount->id);
$this->assertTrue($personOrAccount instanceof Account);
// User can access contacts, and there is contact in system with the email.
// But owner of email is super users, so it shouldn't return contact
Yii::app()->user->userModel = $super;
$this->assertTrue(ContactsModule::loadStartingData());
$this->assertEquals(6, count(ContactState::GetAll()));
$contactStates = ContactState::getByName('Qualified');
$email = new Email();
$email->emailAddress = $emailAddress;
$email2 = new Email();
$email2->emailAddress = 'aabb@example.com';
$contact = new Contact();
$contact->state = $contactStates[0];
$contact->owner = $super;
$contact->firstName = 'Super';
$contact->lastName = 'Man';
$contact->primaryEmail = $email;
$contact->secondaryEmail = $email;
$this->assertTrue($account->save());
$anotherUser->primaryEmail->emailAddress = 'sample45@example.com';
$this->assertTrue($anotherUser->save());
Yii::app()->user->userModel = $user;
$personOrAccount = EmailArchivingUtil::resolvePersonOrAccountByEmailAddress($emailAddress, true, true, false);
$this->assertNull($personOrAccount);
Yii::app()->user->userModel = $super;
$contact->owner = $user;
$this->assertTrue($contact->save());
//.........这里部分代码省略.........
示例11: testDisplayingAOwnedModelAttributeThatIsAlsoDefinedAsAnAttributeOnTheOwningModel
/**
* There was a bug with showing address->state on a contact rows and columns report. it was showing the
* contact->state instead. this test passes after this bug was fixed
*/
public function testDisplayingAOwnedModelAttributeThatIsAlsoDefinedAsAnAttributeOnTheOwningModel()
{
$contactStates = ContactState::getByName('Qualified');
$contact = new Contact();
$contact->owner = Yii::app()->user->userModel;
$contact->title->value = 'Mr.';
$contact->firstName = 'Super';
$contact->lastName = 'Man';
$contact->jobTitle = 'Superhero';
$contact->description = 'Some Description';
$contact->department = 'Red Tape';
$contact->officePhone = '1234567890';
$contact->mobilePhone = '0987654321';
$contact->officeFax = '1222222222';
$contact->state = $contactStates[0];
$contact->primaryAddress->state = 'IL';
$this->assertTrue($contact->save());
$displayAttribute = new DisplayAttributeForReportForm('ContactsModule', 'Contact', Report::TYPE_ROWS_AND_COLUMNS);
$displayAttribute->setModelAliasUsingTableAliasName('abc');
$displayAttribute->attributeIndexOrDerivedType = 'primaryAddress___state';
$this->assertEquals('col0', $displayAttribute->columnAliasName);
$reportResultsRowData = new ReportResultsRowData(array($displayAttribute), 4);
$reportResultsRowData->addModelAndAlias($contact, 'abc');
$model = $reportResultsRowData->getModel('attribute0');
$this->assertEquals('IL', $model->primaryAddress->state);
$this->assertEquals('IL', $reportResultsRowData->attribute0);
}
示例12: testWhetherSearchWorksForTheCustomFieldsPlacedForContactsModuleAfterDeletingTheContact
/**
* @depends testDeleteOfTheContactForTheCustomFieldsPlacedForContactsModule
*/
public function testWhetherSearchWorksForTheCustomFieldsPlacedForContactsModuleAfterDeletingTheContact()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Retrieve the super account id and the super user id.
$accountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
$superUserId = $super->id;
//Retrieve the Contact State (Status) Id based on the name.
$contactState = ContactState::getByName('RecycledC');
$contactStateId = $contactState[0]->id;
//Search a created contact using the customfields.
$this->resetPostArray();
$this->setGetArray(array('ContactsSearchForm' => ContactsDesignerWalkthroughHelperUtil::fetchContactsSearchFormGetData($contactStateId, $superUserId, $accountId), 'ajax' => 'list-view'));
$content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default');
//Assert that the edit contact does not exits after the search.
$this->assertTrue(strpos($content, "No results found.") > 0);
$this->assertFalse(strpos($content, "26378 South Arlington Ave") > 0);
}
示例13: getSecondModel
public static function getSecondModel($user)
{
$industryValues = AccountListViewMergeTestHelper::getIndustryValues();
$account = new Account();
$account->name = 'New Account';
$account->owner = $user;
assert($account->save());
// Not Coding Standard
$contactCustomerStates = ContactState::getByName('Customer');
$contact2 = ContactTestHelper::createContactByNameForOwner('shozin', Yii::app()->user->userModel);
$contact2->title->value = 'Mrs.';
$contact2->state = $contactCustomerStates[0];
$contact2->jobTitle = 'Myhero';
$contact2->source->value = 'Trade Show';
$contact2->companyName = 'Test Company1';
$contact2->account = $account;
$contact2->description = 'Hey Description';
$contact2->industry->value = $industryValues[1];
$contact2->department = 'Black Tape';
$contact2->officePhone = '1234567899';
$contact2->mobilePhone = '0987654123';
$contact2->officeFax = '1222222444';
$contact2->website = 'http://yahoo1.com';
$contact2->primaryEmail->emailAddress = 'test@yahoo.com';
$contact2->primaryEmail->optOut = 0;
$contact2->primaryEmail->isInvalid = 0;
$contact2->secondaryEmail->emailAddress = 'test@gmail.com';
$contact2->secondaryEmail->optOut = 1;
$contact2->secondaryEmail->isInvalid = 1;
$contact2->primaryAddress->street1 = '302';
$contact2->primaryAddress->street2 = '9A/1';
$contact2->primaryAddress->city = 'New Delhi';
$contact2->primaryAddress->state = 'New Delhi';
$contact2->primaryAddress->postalCode = '110005';
$contact2->primaryAddress->country = 'India';
$contact2->secondaryAddress->street1 = 'A-8';
$contact2->secondaryAddress->street2 = 'Sector 56';
$contact2->secondaryAddress->city = 'Gurgaon';
$contact2->secondaryAddress->state = 'Haryana';
$contact2->secondaryAddress->postalCode = '5123-4';
$contact2->secondaryAddress->country = 'IndiaTest';
assert($contact2->save());
// Not Coding Standard
return $contact2;
}
示例14: testContactStateModelAttributesAdapter
public function testContactStateModelAttributesAdapter()
{
Yii::app()->user->userModel = User::getByUsername('super');
$this->assertTrue(ContactsModule::loadStartingData());
$this->assertEquals(6, count(ContactState::GetAll()));
$attributeForm = AttributesFormFactory::createAttributeFormByAttributeName(new Contact(), 'state');
$compareData = array(0 => 'New', 1 => 'In Progress', 2 => 'Recycled', 3 => 'Dead', 4 => 'Qualified', 5 => 'Customer');
$this->assertEquals($compareData, $attributeForm->contactStatesData);
$this->assertEquals(null, $attributeForm->contactStatesLabels);
$this->assertEquals(4, $attributeForm->startingStateOrder);
//Now add new values.
$attributeForm->contactStatesData = array(0 => 'New', 1 => 'In Progress', 2 => 'Recycled', 3 => 'Dead', 4 => 'Qualified', 5 => 'Customer', 6 => 'AAA', 7 => 'BBB');
$contactStatesLabels = array('fr' => array('New', 'In ProgressFr', 'RecycledFr', 'DeadFr', 'QualifiedFr', 'CustomerFr', 'AAAFr', 'BBBFr'));
$attributeForm->contactStatesLabels = $contactStatesLabels;
$attributeForm->startingStateOrder = 5;
$adapter = new ContactStateModelAttributesAdapter(new Contact());
$adapter->setAttributeMetadataFromForm($attributeForm);
$attributeForm = AttributesFormFactory::createAttributeFormByAttributeName(new Contact(), 'state');
$compareData = array(0 => 'New', 1 => 'In Progress', 2 => 'Recycled', 3 => 'Dead', 4 => 'Qualified', 5 => 'Customer', 6 => 'AAA', 7 => 'BBB');
$this->assertEquals($compareData, $attributeForm->contactStatesData);
$this->assertEquals($contactStatesLabels, $attributeForm->contactStatesLabels);
$contactState = ContactState::getByName('Customer');
$this->assertEquals(5, $contactState[0]->order);
$this->assertEquals(5, $attributeForm->startingStateOrder);
//Test removing existing values.
$attributeForm->contactStatesData = array(0 => 'New', 1 => 'In Progress', 2 => 'Recycled', 3 => 'Customer', 4 => 'AAA', 5 => 'BBB');
$attributeForm->startingStateOrder = 5;
$adapter = new ContactStateModelAttributesAdapter(new Contact());
$adapter->setAttributeMetadataFromForm($attributeForm);
$attributeForm = AttributesFormFactory::createAttributeFormByAttributeName(new Contact(), 'state');
$compareData = array(0 => 'New', 1 => 'In Progress', 2 => 'Recycled', 3 => 'Customer', 4 => 'AAA', 5 => 'BBB');
$this->assertEquals($compareData, $attributeForm->contactStatesData);
$this->assertEquals(5, $attributeForm->startingStateOrder);
//Test switching order of existing values.
$attributeForm->contactStatesData = array(0 => 'New', 3 => 'In Progress', 5 => 'Recycled', 1 => 'Customer', 4 => 'AAA', 2 => 'BBB');
$attributeForm->startingStateOrder = 2;
$adapter = new ContactStateModelAttributesAdapter(new Contact());
$adapter->setAttributeMetadataFromForm($attributeForm);
$attributeForm = AttributesFormFactory::createAttributeFormByAttributeName(new Contact(), 'state');
$compareData = array(0 => 'New', 3 => 'In Progress', 5 => 'Recycled', 1 => 'Customer', 4 => 'AAA', 2 => 'BBB');
$this->assertEquals($compareData, $attributeForm->contactStatesData);
$this->assertEquals(2, $attributeForm->startingStateOrder);
//Test switching order of existing values and adding new values mixed in.
$attributeForm->contactStatesData = array(3 => 'New', 6 => 'In Progress', 5 => 'Recycled', 1 => 'Customer', 4 => 'AAA', 2 => 'BBB', 0 => 'CCC');
$attributeForm->startingStateOrder = 2;
$adapter = new ContactStateModelAttributesAdapter(new Contact());
$adapter->setAttributeMetadataFromForm($attributeForm);
$attributeForm = AttributesFormFactory::createAttributeFormByAttributeName(new Contact(), 'state');
$compareData = array(3 => 'New', 6 => 'In Progress', 5 => 'Recycled', 1 => 'Customer', 4 => 'AAA', 2 => 'BBB', 0 => 'CCC');
$this->assertEquals($compareData, $attributeForm->contactStatesData);
$this->assertEquals(2, $attributeForm->startingStateOrder);
//Switching name of existing state
$this->assertEquals(7, ContactState::getCount());
$attributeForm->contactStatesDataExistingValues = array(3 => 'New', 6 => 'In Progress', 5 => 'Recycled', 1 => 'Customer', 4 => 'AAA', 2 => 'BBB', 0 => 'CCC');
$attributeForm->contactStatesData = array(3 => 'New', 6 => 'In Progress Plastic', 5 => 'Recycled', 1 => 'Customer', 4 => 'AAA', 2 => 'BBB', 0 => 'CCC');
$attributeForm->startingStateOrder = 2;
$adapter = new ContactStateModelAttributesAdapter(new Contact());
$adapter->setAttributeMetadataFromForm($attributeForm);
$attributeForm = AttributesFormFactory::createAttributeFormByAttributeName(new Contact(), 'state');
$compareData = array(3 => 'New', 6 => 'In Progress Plastic', 5 => 'Recycled', 1 => 'Customer', 4 => 'AAA', 2 => 'BBB', 0 => 'CCC');
$this->assertEquals($compareData, $attributeForm->contactStatesData);
$this->assertEquals(2, $attributeForm->startingStateOrder);
$this->assertEquals(7, ContactState::getCount());
}
示例15: testGetLeadStateDataFromStartingStateKeyedByIdAndLabelByLanguage
public function testGetLeadStateDataFromStartingStateKeyedByIdAndLabelByLanguage()
{
$newStates = ContactState::getByName('New');
$inProgressStates = ContactState::getByName('In Progress');
$recycledStates = ContactState::getByName('Recycled');
$deadStates = ContactState::getByName('Dead');
$data = LeadsUtil::getLeadStateDataFromStartingStateKeyedByIdAndLabelByLanguage('en');
$compareData = array($newStates[0]->id => 'New', $inProgressStates[0]->id => 'In Progress', $recycledStates[0]->id => 'Recycled', $deadStates[0]->id => 'Dead');
$this->assertEquals($compareData, $data);
$data = LeadsUtil::getLeadStateDataFromStartingStateKeyedByIdAndLabelByLanguage('fr');
$compareData = array($newStates[0]->id => 'Nouveau', $inProgressStates[0]->id => 'En cours', $recycledStates[0]->id => 'Réactivé', $deadStates[0]->id => 'Mort');
$this->assertEquals($compareData, $data);
}