当前位置: 首页>>代码示例>>PHP>>正文


PHP ContactsUtil::getStartingState方法代码示例

本文整理汇总了PHP中ContactsUtil::getStartingState方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactsUtil::getStartingState方法的具体用法?PHP ContactsUtil::getStartingState怎么用?PHP ContactsUtil::getStartingState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContactsUtil的用法示例。


在下文中一共展示了ContactsUtil::getStartingState方法的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 string $modelClassName
  * @param string $attributeName
  * @param mixed $value
  * @param array $mappingRuleData
  */
 public static function sanitizeValue($modelClassName, $attributeName, $value, $mappingRuleData)
 {
     assert('is_string($modelClassName)');
     assert('$attributeName == null');
     assert('$mappingRuleData == 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', 'The 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('ContactsModule', 'The status specified is invalid.'));
         }
         return $state;
     } catch (NotFoundException $e) {
         throw new InvalidValueToSanitizeException(Zurmo::t('ContactsModule', 'The status specified does not exist.'));
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:37,代码来源:ContactStateSanitizerUtil.php

示例2: testResolveContactToSenderOrRecipientForReceivedEmail

 public function testResolveContactToSenderOrRecipientForReceivedEmail()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $message1 = self::$message1;
     $contact = new Contact();
     $contact->firstName = 'Jason';
     $contact->lastName = 'Green';
     $contact->state = ContactsUtil::getStartingState();
     $saved = $contact->save();
     $this->assertTrue($saved);
     $contactId = $contact->id;
     $contact->forget();
     $contact = Contact::getById($contactId);
     $this->assertNull($contact->primaryEmail->emailAddress);
     ArchivedEmailMatchingUtil::resolveContactToSenderOrRecipient($message1, $contact);
     $saved = $message1->save();
     $this->assertTrue($saved);
     $messageId = $message1->id;
     $message1->forget();
     $contact->forget();
     RedBeanModel::forgetAll();
     //simulates crossing page requests
     $message1 = EmailMessage::getById($messageId);
     $contact = Contact::getById($contactId);
     $this->assertEquals(1, $message1->sender->personsOrAccounts->count());
     $castedDownModel = EmailMessageMashableActivityRules::castDownItem($message1->sender->personsOrAccounts[0]);
     $this->assertEquals('Contact', get_class($castedDownModel));
     $this->assertEquals($contact->id, $castedDownModel->id);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:30,代码来源:ArchivedEmailMatchingUtilTest.php

示例3: __construct

 public function __construct(Contact $model = null, $attributeName = null)
 {
     assert('$model != null');
     assert('$attributeName != null && is_string($attributeName)');
     parent::__construct($model, $attributeName);
     $this->contactStatesData = ContactsUtil::getContactStateDataKeyedByOrder();
     $this->contactStatesLabels = ContactsUtil::getContactStateLabelsKeyedByLanguageAndOrder();
     $startingState = ContactsUtil::getStartingState();
     $this->startingStateOrder = $startingState->order;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:10,代码来源:ContactStateAttributeForm.php

示例4: testImportSwitchingOwnerButShouldStillCreate

 /**
  * Test when a normal user who can only view records he owns, tries to import records assigned to another user.
  */
 public function testImportSwitchingOwnerButShouldStillCreate()
 {
     $super = User::getByUsername('super');
     $jim = User::getByUsername('jim');
     Yii::app()->user->userModel = $jim;
     //Confirm Jim can can only view ImportModelTestItems he owns.
     $item = NamedSecurableItem::getByName('ContactsModule');
     $this->assertEquals(Permission::NONE, $item->getEffectivePermissions($jim));
     $testModels = Contact::getAll();
     $this->assertEquals(0, count($testModels));
     $import = new Import();
     $serializedData['importRulesType'] = 'Contacts';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.contacts.tests.unit.files'));
     $this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $ownerColumnMappingData = array('attributeIndexOrDerivedType' => 'owner', 'type' => 'extraColumn', 'mappingRulesData' => array('DefaultModelNameIdMappingRuleForm' => array('defaultModelId' => $super->id), 'UserValueTypeModelAttributeMappingRuleForm' => array('type' => UserValueTypeModelAttributeMappingRuleForm::ZURMO_USER_ID)));
     $startingStateId = ContactsUtil::getStartingState()->id;
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('firstName'), 'column_1' => ImportMappingUtil::makeStringColumnMappingData('lastName'), 'column_2' => $ownerColumnMappingData, 'column_3' => ContactImportTestHelper::makeStateColumnMappingData($startingStateId, 'extraColumn'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Contacts');
     $page = 0;
     $config = array('pagination' => array('pageSize' => 50));
     //This way all rows are processed.
     $dataProvider = new ImportDataProvider($import->getTempTableName(), true, $config);
     $dataProvider->getPagination()->setCurrentPage($page);
     $importResultsUtil = new ImportResultsUtil($import);
     $messageLogger = new ImportMessageLogger();
     ImportUtil::importByDataProvider($dataProvider, $importRules, $mappingData, $importResultsUtil, new ExplicitReadWriteModelPermissions(), $messageLogger);
     $importResultsUtil->processStatusAndMessagesForEachRow();
     //3 models are created, but Jim can't see them since they are assigned to someone else.
     $testModels = Contact::getAll();
     $this->assertEquals(0, count($testModels));
     //Using super, should see all 3 models created.
     Yii::app()->user->userModel = $super;
     $testModels = Contact::getAll();
     $this->assertEquals(3, count($testModels));
     foreach ($testModels as $model) {
         $this->assertEquals(array(Permission::NONE, Permission::NONE), $model->getExplicitActualPermissions($jim));
     }
     //Confirm 4 rows were processed as 'created'.
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
     //Confirm that 0 rows were processed as 'updated'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::UPDATED));
     //Confirm 0 rows were processed as 'errors'.
     $this->assertEquals(0, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR));
     $beansWithErrors = ImportDatabaseUtil::getSubset($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::ERROR);
     $this->assertEquals(0, count($beansWithErrors));
     //Clear out data in table
     Contact::deleteAll();
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:55,代码来源:ContactImportTest.php

示例5: createContactWithAccountByNameForOwner

 public static function createContactWithAccountByNameForOwner($firstName, $owner, $account)
 {
     ContactsModule::loadStartingData();
     $contact = new Contact();
     $contact->firstName = $firstName;
     $contact->lastName = $firstName . 'son';
     $contact->owner = $owner;
     $contact->account = $account;
     $contact->state = ContactsUtil::getStartingState();
     $saved = $contact->save();
     assert('$saved');
     return $contact;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:13,代码来源:ContactTestHelper.php

示例6: testSuperUserCompleteMatchVariations

 public function testSuperUserCompleteMatchVariations()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/matchingList');
     $message1 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message2 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message3 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $contact = ContactTestHelper::createContactByNameForOwner('gail', $super);
     $startingContactState = ContactsUtil::getStartingState();
     $startingLeadState = LeadsUtil::getStartingState();
     //test validating selecting an existing contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'select-contact-form-' . $message1->id, 'AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'contact-inline-create-form-' . $message1->id, 'Contact' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new lead
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'lead-inline-create-form-' . $message1->id, 'Lead' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test selecting existing contact and saving
     $this->assertNull($contact->primaryEmail->emailAddress);
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals('bob.message@zurmotest.com', $contact->primaryEmail->emailAddress);
     $this->assertTrue($message1->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message1->folder);
     //test creating new contact and saving
     $this->assertEquals(1, Contact::getCount());
     $this->setGetArray(array('id' => $message2->id));
     $this->setPostArray(array('Contact' => array($message2->id => array('firstName' => 'George', 'lastName' => 'Patton', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals(2, Contact::getCount());
     $contacts = Contact::getByName('George Patton');
     $contact = $contacts[0];
     $this->assertTrue($message2->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message2->folder);
     //test creating new lead and saving
     $this->assertEquals(2, Contact::getCount());
     $this->setGetArray(array('id' => $message3->id));
     $this->setPostArray(array('Lead' => array($message3->id => array('firstName' => 'Billy', 'lastName' => 'Kid', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals(3, Contact::getCount());
     $contacts = Contact::getByName('Billy Kid');
     $contact = $contacts[0];
     $this->assertTrue($message3->sender->personOrAccount->isSame($contact));
     $this->assertEquals('Archived', $message3->folder);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:51,代码来源:ArchivedEmailMatchingUserWalkthroughTest.php

示例7: actionLoadContactsSampler

 /**
  * Special method to load contacts for marketing functional test.
  */
 public function actionLoadContactsSampler()
 {
     if (!Group::isUserASuperAdministrator(Yii::app()->user->userModel)) {
         throw new NotSupportedException();
     }
     //Load 12 contacts so there is sufficient data for marketing list pagination testing and mass delete.
     for ($i = 1; $i <= 12; $i++) {
         $firstName = 'Test';
         $lastName = 'Contact';
         $owner = Yii::app()->user->userModel;
         $contact = new Contact();
         $contact->firstName = $firstName;
         $contact->lastName = $lastName . ' ' . $i;
         $contact->owner = $owner;
         $contact->state = ContactsUtil::getStartingState();
         $saved = $contact->save();
         assert('$saved');
         if (!$saved) {
             throw new NotSupportedException();
         }
     }
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:25,代码来源:DemoController.php

示例8: testCreateWithRelations

 public function testCreateWithRelations()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $opportunity = OpportunityTestHelper::createOpportunityByNameForOwner('My Opportunity', $super);
     $data['firstName'] = "Freddy";
     $data['lastName'] = "Smith";
     $data['state']['id'] = ContactsUtil::getStartingState()->id;
     $data['modelRelations'] = array('opportunities' => array(array('action' => 'add', 'modelId' => $opportunity->id, 'modelClassName' => 'Opportunity')));
     $response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals($data['firstName'], $response['data']['firstName']);
     $this->assertEquals($data['lastName'], $response['data']['lastName']);
     RedBeanModel::forgetAll();
     $contact = Contact::getById($response['data']['id']);
     $this->assertEquals(1, count($contact->opportunities));
     $this->assertEquals($opportunity->id, $contact->opportunities[0]->id);
     $opportunity = Opportunity::getById($opportunity->id);
     $this->assertEquals(1, count($opportunity->contacts));
     $this->assertEquals($contact->id, $opportunity->contacts[0]->id);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:24,代码来源:ApiRestContactTest.php

示例9: actionSaveConvertedContact

 protected function actionSaveConvertedContact($contact, $account = null, $opportunity = null)
 {
     $contact->account = $account;
     if ($opportunity !== null) {
         $contact->opportunities->add($opportunity);
     }
     $contact->state = ContactsUtil::getStartingState();
     if ($contact->save()) {
         Yii::app()->user->setFlash('notification', Zurmo::t('LeadsModule', 'LeadsModuleSingularLabel successfully converted.', LabelUtil::getTranslationParamsForAllModules()));
         $this->redirect(array('/contacts/default/details', 'id' => $contact->id));
     }
     Yii::app()->user->setFlash('notification', Zurmo::t('LeadsModule', 'LeadsModuleSingularLabel was not converted. An error occurred.'));
     $this->redirect(array('default/details', 'id' => $contact->id));
     Yii::app()->end(0, false);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:15,代码来源:DefaultController.php

示例10: testMakeRecipientsForDynamicTriggeredModelRelation

 public function testMakeRecipientsForDynamicTriggeredModelRelation()
 {
     $form = new DynamicTriggeredModelRelationWorkflowEmailMessageRecipientForm('Account', Workflow::TYPE_ON_SAVE);
     $form->relation = 'contacts';
     $model = new Account();
     $model->name = 'the account';
     $contact = new Contact();
     $contact->firstName = 'Jason';
     $contact->lastName = 'Blue';
     $contact->state = ContactsUtil::getStartingState();
     $contact->primaryEmail->emailAddress = 'jason@something.com';
     $this->assertTrue($contact->save());
     $contact2 = new Contact();
     $contact2->firstName = 'Laura';
     $contact2->lastName = 'Blue';
     $contact2->state = ContactsUtil::getStartingState();
     $contact2->primaryEmail->emailAddress = 'laura@something.com';
     $this->assertTrue($contact2->save());
     $model->contacts->add($contact);
     $model->contacts->add($contact2);
     $this->assertTrue($model->save());
     $recipients = $form->makeRecipients($model, User::getById(self::$bobbyUserId));
     $this->assertEquals(2, count($recipients));
     $this->assertEquals('Jason Blue', $recipients[0]->toName);
     $this->assertEquals('jason@something.com', $recipients[0]->toAddress);
     $this->assertEquals($contact->id, $recipients[0]->personsOrAccounts[0]->id);
     $this->assertEquals('Laura Blue', $recipients[1]->toName);
     $this->assertEquals('laura@something.com', $recipients[1]->toAddress);
     $this->assertEquals($contact2->id, $recipients[1]->personsOrAccounts[0]->id);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:30,代码来源:WorkflowEmailMessageRecipientFormTest.php

示例11: testSuperUserConvertAction

 /**
  * @depends testSuperUserCreateAction
  */
 public function testSuperUserConvertAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $startingLeadState = LeadsUtil::getStartingState();
     $startingContactState = ContactsUtil::getStartingState();
     $leads = Contact::getByName('myNewLead myNewLeadson');
     $this->assertEquals(1, count($leads));
     $lead = $leads[0];
     $this->assertTrue($lead->state == $startingLeadState);
     //Test just going to the convert page.
     $this->setGetArray(array('id' => $lead->id));
     $this->resetPostArray();
     //Test trying to convert by skipping account creation
     $this->runControllerWithNoExceptionsAndGetContent('leads/default/convert');
     $this->setGetArray(array('id' => $lead->id));
     $this->setPostArray(array('AccountSkip' => 'Not Used'));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $leadId = $lead->id;
     $lead->forget();
     $contact = Contact::getById($leadId);
     $this->assertTrue($contact->state == $startingContactState);
     //Test trying to convert by creating a new account.
     $lead5 = LeadTestHelper::createLeadbyNameForOwner('superLead5', $super);
     $this->assertTrue($lead5->state == $startingLeadState);
     $this->setGetArray(array('id' => $lead5->id));
     $this->setPostArray(array('Account' => array('name' => 'someAccountName')));
     $this->assertEquals(0, count(Account::getAll()));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->assertEquals(1, count(Account::getAll()));
     $lead5Id = $lead5->id;
     $lead5->forget();
     $contact5 = Contact::getById($lead5Id);
     $this->assertTrue($contact5->state == $startingContactState);
     $this->assertEquals('someAccountName', $contact5->account->name);
     //Test trying to convert by selecting an existing account
     $account = AccountTestHelper::createAccountbyNameForOwner('someNewAccount', $super);
     $lead6 = LeadTestHelper::createLeadbyNameForOwner('superLead6', $super);
     $this->assertTrue($lead6->state == $startingLeadState);
     $this->setGetArray(array('id' => $lead6->id));
     $this->setPostArray(array('AccountSelectForm' => array('accountId' => $account->id, 'accountName' => 'someNewAccount')));
     $this->assertEquals(2, count(Account::getAll()));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/convert');
     $this->assertEquals(2, count(Account::getAll()));
     $lead6Id = $lead6->id;
     $lead6->forget();
     $contact6 = Contact::getById($lead6Id);
     $this->assertTrue($contact6->state == $startingContactState);
     $this->assertEquals($account, $contact6->account);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:52,代码来源:LeadsSuperUserWalkthroughTest.php

示例12: testSuperUserCompleteMatchVariations

 public function testSuperUserCompleteMatchVariations()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/matchingList');
     $message1 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message1Id = $message1->id;
     $message2 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $message2Id = $message2->id;
     $message3 = EmailMessageTestHelper::createArchivedUnmatchedReceivedMessage($super);
     $contact = ContactTestHelper::createContactByNameForOwner('gail', $super);
     $startingContactState = ContactsUtil::getStartingState();
     $startingLeadState = LeadsUtil::getStartingState();
     //test validating selecting an existing contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'select-contact-form-' . $message1->id, 'AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new contact
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'contact-inline-create-form-' . $message1->id, 'Contact' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test validating creating a new lead
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('ajax' => 'lead-inline-create-form-' . $message1->id, 'Lead' => array($message1->id => array('firstName' => 'Gail', 'lastName' => 'Green', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/completeMatch');
     //test selecting existing contact and saving
     $this->assertNull($contact->primaryEmail->emailAddress);
     $this->setGetArray(array('id' => $message1->id));
     $this->setPostArray(array('AnyContactSelectForm' => array($message1->id => array('contactId' => $contact->id, 'contactName' => 'Some Name'))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $message1->forget();
     $message1 = EmailMessage::getById($message1Id);
     $this->assertNull($contact->primaryEmail->emailAddress);
     $this->assertCount(1, $message1->sender->personsOrAccounts);
     $this->assertTrue($message1->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message1->folder);
     //assert subject of the email going to edit.
     $this->setGetArray(array('id' => $contact->id));
     $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
     $this->assertEquals('A test unmatched archived received email', $message1->subject);
     //edit subject of email message.
     $this->setGetArray(array('id' => $message1->id));
     $createEmailMessageFormData = array('subject' => 'A test unmatched archived received email edited');
     $this->setPostArray(array('ajax' => 'edit-form', 'EmailMessage' => $createEmailMessageFormData));
     $this->runControllerWithRedirectExceptionAndGetUrl('emailMessages/default/edit');
     //assert subject is edited or not.
     $this->setGetArray(array('id' => $contact->id));
     $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
     $this->assertEquals('A test unmatched archived received email edited', $message1->subject);
     //delete email message.
     $this->setGetArray(array('id' => $message1->id));
     $this->runControllerWithRedirectExceptionAndGetUrl('emailMessages/default/delete', true);
     //assert subject not present.
     try {
         EmailMessage::getById($message1->id);
         $this->fail();
     } catch (NotFoundException $e) {
         //success
     }
     //Test the default permission was setted
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message1);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
     //test creating new contact and saving
     $this->assertEquals(1, Contact::getCount());
     $this->setGetArray(array('id' => $message2->id));
     $this->setPostArray(array('Contact' => array($message2->id => array('firstName' => 'George', 'lastName' => 'Patton', 'officePhone' => '456765421', 'state' => array('id' => $startingContactState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $message2->forget();
     $message2 = EmailMessage::getById($message2Id);
     $this->assertEquals(2, Contact::getCount());
     $contacts = Contact::getByName('George Patton');
     $contact = $contacts[0];
     $this->assertCount(1, $message2->sender->personsOrAccounts);
     $this->assertTrue($message2->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message2->folder);
     //Test the default permission was setted
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message2);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
     //test creating new lead and saving
     $this->assertEquals(2, Contact::getCount());
     $this->setGetArray(array('id' => $message3->id));
     $this->setPostArray(array('Lead' => array($message3->id => array('firstName' => 'Billy', 'lastName' => 'Kid', 'officePhone' => '456765421', 'state' => array('id' => $startingLeadState->id)))));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/completeMatch', true);
     $this->assertEquals(3, Contact::getCount());
     $contacts = Contact::getByName('Billy Kid');
     $contact = $contacts[0];
     $this->assertCount(1, $message3->sender->personsOrAccounts);
     $this->assertTrue($message3->sender->personsOrAccounts[0]->isSame($contact));
     $this->assertEquals('Archived', $message3->folder);
     //Test the default permission was setted
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($message3);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:96,代码来源:ArchivedEmailMatchingUserWalkthroughTest.php

示例13: testContactsUtilGetAndSetStartingStateById

 public function testContactsUtilGetAndSetStartingStateById()
 {
     $expectedStartingStateId = ContactsUtil::getStartingState()->id;
     $contactStates = ContactState::getAll();
     foreach ($contactStates as $contactState) {
         if ($contactState->id != $expectedStartingStateId) {
             $otherStateId = $contactState->id;
             break;
         }
     }
     $startingStateId = ContactsUtil::getStartingStateId();
     $this->assertEquals($expectedStartingStateId, $startingStateId);
     ContactsUtil::setStartingStateById($otherStateId);
     $startingStateId = ContactsUtil::getStartingStateId();
     $this->assertEquals($otherStateId, $startingStateId);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:16,代码来源:ContactTest.php

示例14: testSuperUserCreateFromRelationAction

 /**
  * @depends testSuperUserCreateAction
  */
 public function testSuperUserCreateFromRelationAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $startingState = ContactsUtil::getStartingState();
     $contacts = Contact::getAll();
     $this->assertEquals(12, count($contacts));
     $account = Account::getByName('superAccount2');
     $account[0]->billingAddress->street1 = 'some street';
     $account[0]->shippingAddress->street1 = 'some street 2';
     $saved = $account[0]->save();
     $this->assertTrue($saved);
     $opportunity = OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp', $super, $account[0]);
     //Create a new contact from a related account.
     $this->setGetArray(array('relationAttributeName' => 'account', 'relationModelId' => $account[0]->id, 'relationModuleId' => 'accounts', 'redirectUrl' => 'someRedirect'));
     $this->setPostArray(array('Contact' => array('firstName' => 'another', 'lastName' => 'anotherson', 'officePhone' => '456765421', 'state' => array('id' => $startingState->id))));
     $this->runControllerWithRedirectExceptionAndGetContent('contacts/default/createFromRelation');
     $contacts = Contact::getByName('another anotherson');
     $this->assertEquals(1, count($contacts));
     $this->assertTrue($contacts[0]->id > 0);
     $this->assertTrue($contacts[0]->owner == $super);
     $this->assertTrue($contacts[0]->account == $account[0]);
     $this->assertTrue($contacts[0]->state == $startingState);
     $this->assertEquals('some street', $contacts[0]->primaryAddress->street1);
     $this->assertEquals('some street 2', $contacts[0]->secondaryAddress->street1);
     $this->assertEquals('some street', $contacts[0]->account->billingAddress->street1);
     $this->assertEquals('some street 2', $contacts[0]->account->shippingAddress->street1);
     $this->assertEquals('456765421', $contacts[0]->officePhone);
     $contacts = Contact::getAll();
     $this->assertEquals(13, count($contacts));
     //Create a new contact from a related opportunity
     $this->setGetArray(array('relationAttributeName' => 'opportunities', 'relationModelId' => $opportunity->id, 'relationModuleId' => 'opportunities', 'redirectUrl' => 'someRedirect'));
     $this->setPostArray(array('Contact' => array('firstName' => 'bnother', 'lastName' => 'bnotherson', 'officePhone' => '456765421', 'state' => array('id' => $startingState->id))));
     $this->runControllerWithRedirectExceptionAndGetContent('contacts/default/createFromRelation');
     $contacts = Contact::getByName('bnother bnotherson');
     $this->assertEquals(1, count($contacts));
     $this->assertTrue($contacts[0]->id > 0);
     $this->assertTrue($contacts[0]->owner == $super);
     $this->assertEquals(1, $contacts[0]->opportunities->count());
     $this->assertTrue($contacts[0]->opportunities[0] == $opportunity);
     $this->assertTrue($contacts[0]->state == $startingState);
     $this->assertEquals('456765421', $contacts[0]->officePhone);
     $contacts = Contact::getAll();
     $this->assertEquals(14, count($contacts));
     //todo: test save with account.
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:48,代码来源:ContactsSuperUserWalkthroughTest.php

示例15: testProcessDueAutoresponderItemWithModelUrlMergeTags

 /**
  * @depends testProcessDueAutoresponderItemWithReturnPath
  */
 public function testProcessDueAutoresponderItemWithModelUrlMergeTags()
 {
     $email = new Email();
     $email->emailAddress = 'demo@zurmo.com';
     $contact = ContactTestHelper::createContactByNameForOwner('contact 09', $this->user);
     $contact->primaryEmail = $email;
     $contact->state = ContactsUtil::getStartingState();
     $this->assertTrue($contact->save());
     $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 09', 'description', 'CustomFromName', 'custom@from.com');
     $autoresponder = AutoresponderTestHelper::createAutoresponder('subject 09', 'Url: [[MODEL^URL]]', 'Click <a href="[[MODEL^URL]]">here</a>', 1, Autoresponder::OPERATION_SUBSCRIBE, true, $marketingList);
     $processed = 0;
     $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $autoresponderItem = AutoresponderItemTestHelper::createAutoresponderItem($processed, $processDateTime, $autoresponder, $contact);
     $this->processDueItem($autoresponderItem);
     $this->assertEquals(1, $autoresponderItem->processed);
     $emailMessage = $autoresponderItem->emailMessage;
     $this->assertNotEquals($autoresponder->textContent, $emailMessage->content->textContent);
     $this->assertNotEquals($autoresponder->htmlContent, $emailMessage->content->htmlContent);
     $this->assertContains('/contacts/default/details?id=' . $contact->id, $emailMessage->content->textContent);
     $this->assertContains('/contacts/default/details?id=' . $contact->id, $emailMessage->content->htmlContent);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:24,代码来源:AutoresponderItemsUtilTest.php


注:本文中的ContactsUtil::getStartingState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。