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


PHP Contact::getByName方法代码示例

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


在下文中一共展示了Contact::getByName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSaveAndRetrievePortlet

 public function testSaveAndRetrievePortlet()
 {
     $user = UserTestHelper::createBasicUser('Billy');
     $contacts = Contact::getByName('superContact superContactson');
     $portlet = new Portlet();
     $portlet->column = 2;
     $portlet->position = 5;
     $portlet->layoutId = 'Test';
     $portlet->collapsed = true;
     $portlet->viewType = 'ContactsForAccountRelatedList';
     $portlet->serializedViewData = serialize(array('title' => 'Testing Title'));
     $portlet->user = $user;
     $this->assertTrue($portlet->save());
     $portlet = Portlet::getById($portlet->id);
     $params = array('controllerId' => 'test', 'relationModuleId' => 'test', 'relationModel' => $contacts[0], 'redirectUrl' => 'someRedirect');
     $portlet->params = $params;
     $unserializedViewData = unserialize($portlet->serializedViewData);
     $this->assertEquals(2, $portlet->column);
     $this->assertEquals(5, $portlet->position);
     $this->assertEquals('Testing Title', $portlet->getTitle());
     $this->assertEquals(false, $portlet->isEditable());
     $this->assertEquals('Test', $portlet->layoutId);
     //$this->assertEquals(true,                  $portlet->collapsed); //reenable once working
     $this->assertEquals('ContactsForAccountRelatedList', $portlet->viewType);
     $this->assertEquals($user->id, $portlet->user->id);
     $view = $portlet->getView();
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:27,代码来源:ContactsRelatedListPortletTest.php

示例2: testGetItemIdsByModelAndUser

 public function testGetItemIdsByModelAndUser()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $headquarters = Account::getByName('Headquarters');
     $headquarters = $headquarters[0];
     $division1 = Account::getByName('Division1');
     $division1 = $division1[0];
     $division2 = Account::getByName('Division2');
     $division2 = $division2[0];
     $ceo = Contact::getByName('ceo ceoson');
     $ceo = $ceo[0];
     $div1President = Contact::getByName('div1 President div1 Presidentson');
     $div1President = $div1President[0];
     $div2President = Contact::getByName('div2 President div2 Presidentson');
     $div2President = $div2President[0];
     $opportunity = Opportunity::getByName('big opp');
     $opportunity = $opportunity[0];
     $opportunityDiv1 = Opportunity::getByName('div1 small opp');
     $opportunityDiv1 = $opportunityDiv1[0];
     $opportunityDiv2 = Opportunity::getByName('div2 small opp');
     $opportunityDiv2 = $opportunityDiv2[0];
     //Headquarter rollup should include all items created so far.
     $this->assertEquals(2, $headquarters->accounts->count());
     $itemIds = ModelRollUpUtil::getItemIdsByModelAndUser($headquarters, $super);
     $compareItemIds = array();
     $this->assertEquals(9, count($itemIds));
     $this->assertTrue(in_array($headquarters->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($division1->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($division2->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($ceo->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($div1President->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($div2President->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($opportunity->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($opportunityDiv1->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($opportunityDiv2->getClassId('Item'), $itemIds));
     //Ceo rollup would only include the ceo and his opportunity
     $itemIds = ModelRollUpUtil::getItemIdsByModelAndUser($ceo, $super);
     $compareItemIds = array();
     $this->assertEquals(2, count($itemIds));
     $this->assertTrue(in_array($ceo->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($opportunity->getClassId('Item'), $itemIds));
     //Big Opp rollup will only include big opp and ceo
     $itemIds = ModelRollUpUtil::getItemIdsByModelAndUser($opportunity, $super);
     $compareItemIds = array();
     $this->assertEquals(2, count($itemIds));
     $this->assertTrue(in_array($ceo->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($opportunity->getClassId('Item'), $itemIds));
     //Division 1 rollup will only include things related to division 1
     $itemIds = ModelRollUpUtil::getItemIdsByModelAndUser($division1, $super);
     $compareItemIds = array();
     $this->assertEquals(3, count($itemIds));
     $this->assertTrue(in_array($division1->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($div1President->getClassId('Item'), $itemIds));
     $this->assertTrue(in_array($opportunityDiv1->getClassId('Item'), $itemIds));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:56,代码来源:ModelsRollUpTest.php

示例3: validatePrimaryModelData

 protected function validatePrimaryModelData()
 {
     $this->assertEmpty(Contact::getByName('shozin shozinson'));
     $this->validateTask('firstName', 'shozin');
     $this->validateTask('lastName', 'shozinson');
     $this->validateNote('firstName', 'shozin');
     $this->validateNote('lastName', 'shozinson');
     $this->validateMeeting('firstName', 'shozin');
     $this->validateMeeting('lastName', 'shozinson');
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:10,代码来源:LeadListViewMergeUtilTest.php

示例4: testSuperUserEditControllerAction

 public function testSuperUserEditControllerAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     //Default Controller actions requiring some sort of parameter via POST or GET
     //Load Model Edit Views
     $contacts = Contact::getByName('superContact superContactson');
     $products = Product::getAll();
     $this->assertEquals(1, count($contacts));
     $this->assertEquals(1, count($products));
     $superProductId = self::getModelIdByModelNameAndName('Product', 'My Product 1');
     $this->setGetArray(array('id' => $superProductId));
     $this->runControllerWithNoExceptionsAndGetContent('products/default/edit');
     //Save product.
     $superProduct = Product::getById($superProductId);
     $this->setPostArray(array('Product' => array('contact' => array('id' => $contacts[0]->id), 'opportunity' => array('id' => ''), 'owner' => array('id' => $super->id), 'explicitReadWriteModelPermissions' => array('type' => ExplicitReadWriteModelPermissionsUtil::MIXED_TYPE_EVERYONE_GROUP, 'nonEveryoneGroup' => ''))));
     //Test having a failed validation on the product during save.
     $this->setGetArray(array('id' => $superProductId));
     $content = $this->runControllerWithRedirectExceptionAndGetContent('products/default/edit');
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:19,代码来源:ProductsSuperUserSaveWalkthroughTest.php

示例5: 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

示例6: testSimpleUserImportWhereAllRowsSucceed

 public function testSimpleUserImportWhereAllRowsSucceed()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $contacts = Contact::getAll();
     $this->assertEquals(0, count($contacts));
     $import = new Import();
     $serializedData['importRulesType'] = 'Leads';
     $serializedData['firstRowIsHeaderRow'] = true;
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $import->getTempTableName(), true, Yii::getPathOfAlias('application.modules.leads.tests.unit.files'));
     $this->assertEquals(4, ImportDatabaseUtil::getCount($import->getTempTableName()));
     // includes header rows.
     $currency = Currency::getByCode(Yii::app()->currencyHelper->getBaseCode());
     $mappingData = array('column_0' => ImportMappingUtil::makeStringColumnMappingData('firstName'), 'column_1' => ImportMappingUtil::makeStringColumnMappingData('lastName'), 'column_2' => ImportMappingUtil::makeStringColumnMappingData('jobTitle'), 'column_3' => ImportMappingUtil::makeStringColumnMappingData('officePhone'), 'column_4' => ImportMappingUtil::makeStringColumnMappingData('officeFax'), 'column_5' => ImportMappingUtil::makeStringColumnMappingData('department'), 'column_6' => ImportMappingUtil::makeUrlColumnMappingData('website'), 'column_7' => ImportMappingUtil::makeTextAreaColumnMappingData('description'), 'column_8' => ImportMappingUtil::makeStringColumnMappingData('primaryAddress__city'), 'column_9' => ImportMappingUtil::makeStringColumnMappingData('primaryAddress__country'), 'column_10' => ImportMappingUtil::makeStringColumnMappingData('primaryAddress__postalCode'), 'column_11' => ImportMappingUtil::makeStringColumnMappingData('primaryAddress__state'), 'column_12' => ImportMappingUtil::makeStringColumnMappingData('primaryAddress__street1'), 'column_13' => ImportMappingUtil::makeStringColumnMappingData('primaryAddress__street2'), 'column_14' => ImportMappingUtil::makeEmailColumnMappingData('primaryEmail__emailAddress'), 'column_15' => ImportMappingUtil::makeBooleanColumnMappingData('primaryEmail__isInvalid'), 'column_16' => ImportMappingUtil::makeBooleanColumnMappingData('primaryEmail__optOut'), 'column_17' => ImportMappingUtil::makeDropDownColumnMappingData('source'), 'column_18' => LeadImportTestHelper::makeStateColumnMappingData(), 'column_19' => ImportMappingUtil::makeDropDownColumnMappingData('industry'), 'column_20' => ImportMappingUtil::makeStringColumnMappingData('companyName'));
     $importRules = ImportRulesUtil::makeImportRulesByType('Leads');
     $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();
     //Confirm that 3 models where created.
     $contacts = Contact::getAll();
     $this->assertEquals(3, count($contacts));
     $contacts = Contact::getByName('contact1 contact1son');
     $this->assertEquals(1, count($contacts[0]));
     $this->assertEquals('contact1', $contacts[0]->firstName);
     $this->assertEquals('contact1son', $contacts[0]->lastName);
     $this->assertEquals('president', $contacts[0]->jobTitle);
     $this->assertEquals(123456, $contacts[0]->officePhone);
     $this->assertEquals(555, $contacts[0]->officeFax);
     $this->assertEquals('executive', $contacts[0]->department);
     $this->assertEquals('http://www.contact1.com', $contacts[0]->website);
     $this->assertEquals('desc1', $contacts[0]->description);
     $this->assertEquals('city1', $contacts[0]->primaryAddress->city);
     $this->assertEquals('country1', $contacts[0]->primaryAddress->country);
     $this->assertEquals('postal1', $contacts[0]->primaryAddress->postalCode);
     $this->assertEquals('state1', $contacts[0]->primaryAddress->state);
     $this->assertEquals('street11', $contacts[0]->primaryAddress->street1);
     $this->assertEquals('street21', $contacts[0]->primaryAddress->street2);
     $this->assertEquals('a@a.com', $contacts[0]->primaryEmail->emailAddress);
     $this->assertEquals(null, $contacts[0]->primaryEmail->isInvalid);
     $this->assertEquals(null, $contacts[0]->primaryEmail->optOut);
     $this->assertEquals('Self-Generated', $contacts[0]->source->value);
     $this->assertEquals('New', $contacts[0]->state->name);
     $this->assertEquals('Automotive', $contacts[0]->industry->value);
     $this->assertEquals('company1', $contacts[0]->companyName);
     $contacts = Contact::getByName('contact2 contact2son');
     $this->assertEquals(1, count($contacts[0]));
     $this->assertEquals('contact2', $contacts[0]->firstName);
     $this->assertEquals('contact2son', $contacts[0]->lastName);
     $this->assertEquals('president2', $contacts[0]->jobTitle);
     $this->assertEquals(223456, $contacts[0]->officePhone);
     $this->assertEquals(655, $contacts[0]->officeFax);
     $this->assertEquals('executive2', $contacts[0]->department);
     $this->assertEquals('http://www.contact2.com', $contacts[0]->website);
     $this->assertEquals('desc2', $contacts[0]->description);
     $this->assertEquals('city2', $contacts[0]->primaryAddress->city);
     $this->assertEquals('country2', $contacts[0]->primaryAddress->country);
     $this->assertEquals('postal2', $contacts[0]->primaryAddress->postalCode);
     $this->assertEquals('state2', $contacts[0]->primaryAddress->state);
     $this->assertEquals('street12', $contacts[0]->primaryAddress->street1);
     $this->assertEquals('street22', $contacts[0]->primaryAddress->street2);
     $this->assertEquals('b@b.com', $contacts[0]->primaryEmail->emailAddress);
     $this->assertEquals(null, $contacts[0]->primaryEmail->isInvalid);
     $this->assertEquals(null, $contacts[0]->primaryEmail->optOut);
     $this->assertEquals('Tradeshow', $contacts[0]->source->value);
     $this->assertEquals('Recycled', $contacts[0]->state->name);
     $this->assertEquals('Banking', $contacts[0]->industry->value);
     $this->assertEquals('company2', $contacts[0]->companyName);
     $contacts = Contact::getByName('contact3 contact3son');
     $this->assertEquals(1, count($contacts[0]));
     $this->assertEquals('contact3', $contacts[0]->firstName);
     $this->assertEquals('contact3son', $contacts[0]->lastName);
     $this->assertEquals('president3', $contacts[0]->jobTitle);
     $this->assertEquals(323456, $contacts[0]->officePhone);
     $this->assertEquals(755, $contacts[0]->officeFax);
     $this->assertEquals('executive3', $contacts[0]->department);
     $this->assertEquals('http://www.contact3.com', $contacts[0]->website);
     $this->assertEquals('desc3', $contacts[0]->description);
     $this->assertEquals('city3', $contacts[0]->primaryAddress->city);
     $this->assertEquals('country3', $contacts[0]->primaryAddress->country);
     $this->assertEquals('postal3', $contacts[0]->primaryAddress->postalCode);
     $this->assertEquals('state3', $contacts[0]->primaryAddress->state);
     $this->assertEquals('street13', $contacts[0]->primaryAddress->street1);
     $this->assertEquals('street23', $contacts[0]->primaryAddress->street2);
     $this->assertEquals('c@c.com', $contacts[0]->primaryEmail->emailAddress);
     $this->assertEquals('1', $contacts[0]->primaryEmail->isInvalid);
     $this->assertEquals('1', $contacts[0]->primaryEmail->optOut);
     $this->assertEquals('Inbound Call', $contacts[0]->source->value);
     $this->assertEquals('New', $contacts[0]->state->name);
     $this->assertEquals('Energy', $contacts[0]->industry->value);
     $this->assertEquals('company3', $contacts[0]->companyName);
     //Confirm 3 rows were processed as 'created'.
     $this->assertEquals(3, ImportDatabaseUtil::getCount($import->getTempTableName(), "status = " . ImportRowDataResultsUtil::CREATED));
     //Confirm that 0 rows were processed as 'updated'.
//.........这里部分代码省略.........
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:101,代码来源:LeadImportTest.php

示例7: testRunCaseFive

 /**
  * Check if only new messages are pulled from dropdown
  * Also check case if message will be matched with user/contact/account primary email
  *
  * @depends testRunCaseFour
  */
 public function testRunCaseFive()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     $user = User::getByUsername('steve');
     Yii::app()->imap->connect();
     ContactTestHelper::createContactByNameForOwner('contact', $user);
     $contacts = Contact::getByName('contact contactson');
     $contacts[0]->primaryEmail->emailAddress = Yii::app()->params['emailTestAccounts']['testEmailAddress'];
     $this->assertTrue($contacts[0]->save());
     AccountTestHelper::createAccountByNameForOwner('account', $user);
     $accounts = Account::getByName('account');
     $accounts[0]->primaryEmail->emailAddress = Yii::app()->params['emailTestAccounts']['testEmailAddress'];
     $this->assertTrue($accounts[0]->save());
     $john = User::getByUsername('john');
     $john->primaryEmail->emailAddress = Yii::app()->params['emailTestAccounts']['testEmailAddress'];
     $this->assertTrue($john->save());
     EmailMessage::deleteAll();
     Yii::app()->imap->deleteMessages(true);
     // Check if there are no emails in dropbox
     $job = new EmailArchivingJob();
     $this->assertTrue($job->run());
     $this->assertEquals(0, EmailMessage::getCount());
     $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed();
     $this->assertEquals(0, $imapStats->Nmsgs);
     //Now user send email to another user, and to dropbox
     $pathToFiles = Yii::getPathOfAlias('application.modules.emailMessages.tests.unit.files');
     Yii::app()->emailHelper->sendRawEmail("Email from Steve 3", $user->primaryEmail->emailAddress, array(Yii::app()->params['emailTestAccounts']['testEmailAddress']), 'Email from Steve', '<strong>Email</strong> from Steve', null, array(Yii::app()->imap->imapUsername), null, self::$userMailer);
     sleep(30);
     $job = new EmailArchivingJob();
     $this->assertTrue($job->run());
     $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed();
     $this->assertEquals(0, $imapStats->Nmsgs);
     $this->assertEquals(2, EmailMessage::getCount());
     $emailMessages = EmailMessage::getAll();
     $emailMessage = $emailMessages[1];
     $this->assertEquals('Email from Steve 3', $emailMessage->subject);
     $this->assertEquals('Email from Steve', trim($emailMessage->content->textContent));
     $this->assertEquals('<!-- zurmo css inline --><strong>Email</strong> from Steve', preg_replace("/\r|\n/", "", $emailMessage->content->htmlContent));
     $this->assertEquals($user->primaryEmail->emailAddress, $emailMessage->sender->fromAddress);
     $this->assertEquals(1, count($emailMessage->recipients));
     $recipient = $emailMessage->recipients[0];
     $this->assertCount(3, $recipient->personsOrAccounts);
     $this->assertEquals($recipient->toAddress, Yii::app()->params['emailTestAccounts']['testEmailAddress']);
     $this->assertEquals(EmailMessageRecipient::TYPE_TO, $recipient->type);
     $this->assertEquals(EmailFolder::TYPE_ARCHIVED, $emailMessage->folder->type);
     $job = new EmailArchivingJob();
     $this->assertTrue($job->run());
     $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed();
     $this->assertEquals(0, $imapStats->Nmsgs);
     $this->assertEquals(2, EmailMessage::getCount());
     $this->assertEquals(1, Notification::getCountByTypeAndUser('EmailMessageArchivingEmailAddressNotMatching', $user));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:59,代码来源:EmailArchivingJobTest.php

示例8: testAttributesToAccountWithNoPostData

 /**
  * @depends testAttributesToAccount
  */
 public function testAttributesToAccountWithNoPostData()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $postData = array('name' => '');
     $contacts = Contact::getByName('Super Man');
     $this->assertEquals(1, count($contacts));
     $contact = $contacts[0];
     $this->assertEquals('ABC Company', $contact->companyName);
     $this->assertEquals('1234567890', $contact->officePhone);
     $account = new Account();
     $this->assertEmpty($account->name);
     $this->assertEmpty($account->officePhone);
     $account = LeadsUtil::attributesToAccountWithNoPostData($contact, $account, $postData);
     $this->assertEquals('1234567890', $account->officePhone);
     $this->assertEquals(null, $account->name);
     $postData = array();
     $contacts = Contact::getByName('Super Man');
     $this->assertEquals(1, count($contacts));
     $contact = $contacts[0];
     $this->assertEquals('ABC Company', $contact->companyName);
     $this->assertEquals('1234567890', $contact->officePhone);
     $account = new Account();
     $this->assertEmpty($account->name);
     $this->assertEmpty($account->officePhone);
     $account = LeadsUtil::attributesToAccountWithNoPostData($contact, $account, $postData);
     $this->assertEquals('1234567890', $account->officePhone);
     $this->assertEquals('ABC Company', $account->name);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:31,代码来源:LeadTest.php

示例9: testResolveContactWithLink

 public function testResolveContactWithLink()
 {
     $contacts = Contact::getByName('test testson');
     $content = CampaignItemSummaryListViewColumnAdapter::resolveContactWithLink($contacts[0]);
     $this->assertContains('test testson', $content);
     //Benny dont have access to contact
     Yii::app()->user->userModel = User::getByUsername('benny');
     $content = CampaignItemSummaryListViewColumnAdapter::resolveContactWithLink($contacts[0]);
     $this->assertContains('You cannot see this contact due to limited access', $content);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:10,代码来源:CampaignItemSummaryListViewColumnAdapterTest.php

示例10: testAttachRecipientsToMessage

 public function testAttachRecipientsToMessage()
 {
     $billy = User::getByUsername('billy');
     Yii::app()->user->userModel = $billy;
     $emailMessage = new EmailMessage();
     //Attach non personOrAccount recipient
     EmailMessageUtil::attachRecipientsToMessage(array('a@zurmo.com', 'b@zurmo.com', 'c@zurmo.com'), $emailMessage, EmailMessageRecipient::TYPE_TO);
     $this->assertEquals('3', count($emailMessage->recipients));
     $this->assertLessThan(0, $emailMessage->recipients[0]->personOrAccount->id);
     $this->assertLessThan(0, $emailMessage->recipients[1]->personOrAccount->id);
     $this->assertLessThan(0, $emailMessage->recipients[2]->personOrAccount->id);
     $this->assertEquals(EmailMessageRecipient::TYPE_TO, $emailMessage->recipients[0]->type);
     $this->assertEquals(EmailMessageRecipient::TYPE_TO, $emailMessage->recipients[1]->type);
     $this->assertEquals(EmailMessageRecipient::TYPE_TO, $emailMessage->recipients[2]->type);
     //Attach personOrAccount recipient
     EmailMessageUtil::attachRecipientsToMessage(array('sally@zurmoland.com', 'molly@zurmoland.com'), $emailMessage, EmailMessageRecipient::TYPE_BCC);
     $this->assertEquals('5', count($emailMessage->recipients));
     $contacts = Contact::getByName('sally sallyson');
     $this->assertEquals($emailMessage->recipients[3]->personOrAccount->id, $contacts[0]->id);
     $this->assertEquals(EmailMessageRecipient::TYPE_BCC, $emailMessage->recipients[3]->type);
     //User billy dont have permision to molly contact
     Yii::app()->user->userModel = User::getByUsername('super');
     $contacts = Contact::getByName('molly mollyson');
     $this->assertNotEquals($emailMessage->recipients[4]->personOrAccount->id, $contacts[0]->id);
     $this->assertEquals($emailMessage->recipients[4]->toAddress, $contacts[0]->primaryEmail->emailAddress);
     $this->assertEquals(EmailMessageRecipient::TYPE_BCC, $emailMessage->recipients[4]->type);
     //Attach an empty email
     EmailMessageUtil::attachRecipientsToMessage(array(''), $emailMessage, EmailMessageRecipient::TYPE_CC);
     $this->assertEquals('5', count($emailMessage->recipients));
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:30,代码来源:EmailMessageUtilTest.php

示例11: testSuperUserCopyAction

 /**
  * @depends testSuperUserCreateFromRelationAction
  */
 public function testSuperUserCopyAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $contacts = Contact::getByName('myNewContact myNewContactson');
     $this->assertCount(1, $contacts);
     $postArray = array('Contact' => array('firstName' => 'myNewContact', 'lastName' => 'myNewContactson', 'jobTitle' => 'job title', 'account' => array('name' => 'Linked account'), 'department' => 'Some department', 'officePhone' => '456765421', 'mobilePhone' => '958462315', 'officeFax' => '123456789', 'primaryEmail' => array('emailAddress' => 'a@a.com'), 'secondaryEmail' => array('emailAddress' => 'b@b.com'), 'primaryAddress' => array('street1' => 'Street1', 'street2' => 'Street2', 'city' => 'City', 'state' => 'State', 'postalCode' => '12345', 'country' => 'Country'), 'secondaryAddress' => array('street1' => 'Street1', 'street2' => 'Street2', 'city' => 'City', 'state' => 'State', 'postalCode' => '12345', 'country' => 'Country'), 'description' => 'some description'));
     $this->updateModelValuesFromPostArray($contacts[0], $postArray);
     $this->assertModelHasValuesFromPostArray($contacts[0], $postArray);
     $this->assertTrue($contacts[0]->save());
     $this->assertTrue($this->checkCopyActionResponseAttributeValuesFromPostArray($contacts[0], $postArray));
     $postArray['Contact']['firstName'] = 'myClonedContact';
     $postArray['Contact']['lastName'] = 'myClonedContactson';
     $postArray['Contact']['state'] = array('id' => LeadsUtil::getStartingState()->id);
     $this->setGetArray(array('id' => $contacts[0]->id));
     $this->setPostArray($postArray);
     $this->runControllerWithRedirectExceptionAndGetUrl('contacts/default/copy');
     $contacts = Contact::getByName('myClonedContact myClonedContactson');
     $this->assertCount(1, $contacts);
     $this->assertTrue($contacts[0]->owner->isSame($super));
     unset($postArray['Contact']['state']);
     $this->assertModelHasValuesFromPostArray($contacts[0], $postArray);
     $contacts = Contact::getAll();
     $this->assertCount(15, $contacts);
     $contacts = Contact::getByName('myClonedContact myClonedContactson');
     $this->assertCount(1, $contacts);
     $this->assertTrue($contacts[0]->delete());
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:30,代码来源:ContactsSuperUserWalkthroughTest.php

示例12: testSubscribeActionAfterOptOutActionDisableOptOut

 /**
  * @depends testOptOutAction
  */
 public function testSubscribeActionAfterOptOutActionDisableOptOut()
 {
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $marketingList = MarketingList::getByName('marketingList 04');
     $this->assertNotEmpty($marketingList);
     $marketingList = $marketingList[0];
     $marketingListId = $marketingList->id;
     $contact = Contact::getByName('contact 05 contact 05son');
     $this->assertNotEmpty($contact);
     $contact = $contact[0];
     $this->assertEquals(1, $contact->primaryEmail->optOut);
     $personId = $contact->getClassId('Person');
     $member = MarketingListMember::getByMarketingListIdContactIdAndSubscribed($marketingList->id, $contact->id, 1);
     $this->assertNotEmpty($member);
     Yii::app()->user->userModel = null;
     $hash = EmailMessageActivityUtil::resolveHashForUnsubscribeAndManageSubscriptionsUrls($personId, $marketingListId, 1, 'AutoresponderItem', false);
     $this->setGetArray(array('hash' => $hash));
     @$this->runControllerWithRedirectExceptionAndGetUrl($this->subscribeUrl);
     $content = $this->runControllerWithNoExceptionsAndGetContent($this->manageSubscriptionsUrl);
     $this->assertTrue(strpos($content, '<td>marketingList 01</td>') !== false);
     $this->assertTrue(strpos($content, '<td>marketingList 03</td>') !== false);
     $this->assertTrue(strpos($content, 'marketingLists/external/subscribe?hash=') !== false);
     $this->assertTrue(strpos($content, 'id="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_') !== false);
     $this->assertTrue(strpos($content, 'id="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_') !== false);
     $this->assertTrue(strpos($content, 'type="radio" name="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_') !== false);
     $this->assertTrue(strpos($content, 'id="marketingListsManageSubscriptionListView-toggleUnsubscribed_' . $marketingListId . '_0" checked="checked" type="radio" name="marketingListsManage' . 'SubscriptionListView-toggleUnsubscribed_' . $marketingListId) !== false);
     $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $contact = Contact::getByName('contact 05 contact 05son');
     $this->assertNotEmpty($contact);
     $contact = $contact[0];
     $this->assertEquals(0, $contact->primaryEmail->optOut);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:35,代码来源:MarketingListsExternalControllerWalkthroughTest.php

示例13: 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

示例14: setSelectedModels

 protected function setSelectedModels()
 {
     $contacts = Contact::getByName('Super Man');
     $this->selectedModels[] = $contacts[0];
     $contacts = Contact::getByName('shozin shozinson');
     $this->selectedModels[] = $contacts[0];
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:7,代码来源:ContactListViewMergeUtilTest.php

示例15: testSuperUserCreateFromRelationAction

 /**
  * @depends testSuperUserCreateAction
  */
 public function testSuperUserCreateFromRelationAction()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $currencies = Currency::getAll();
     $opportunities = Opportunity::getAll();
     $this->assertEquals(12, count($opportunities));
     $account = Account::getByName('superAccount2');
     $contact = Contact::getByName('superContact2 superContact2son');
     $this->assertEquals(1, count($contact));
     //Create a new contact from a related account.
     $this->setGetArray(array('relationAttributeName' => 'account', 'relationModelId' => $account[0]->id, 'relationModuleId' => 'accounts', 'redirectUrl' => 'someRedirect'));
     $this->setPostArray(array('Opportunity' => array('name' => 'myUltraNewOpportunity', 'description' => '456765421', 'closeDate' => '11/1/11', 'amount' => array('value' => '545', 'currency' => array('id' => $currencies[0]->id)), 'stage' => array('value' => 'Negotiating'))));
     $this->runControllerWithRedirectExceptionAndGetContent('opportunities/default/createFromRelation');
     $opportunities = Opportunity::getByName('myUltraNewOpportunity');
     $this->assertEquals(1, count($opportunities));
     $this->assertTrue($opportunities[0]->id > 0);
     $this->assertTrue($opportunities[0]->owner == $super);
     $this->assertTrue($opportunities[0]->account == $account[0]);
     $this->assertEquals('456765421', $opportunities[0]->description);
     $this->assertEquals('545', $opportunities[0]->amount->value);
     $this->assertEquals('2011-11-01', $opportunities[0]->closeDate);
     $this->assertEquals('Negotiating', $opportunities[0]->stage->value);
     $opportunities = Opportunity::getAll();
     $this->assertEquals(13, count($opportunities));
     //Create a new contact from a related opportunity
     $this->setGetArray(array('relationAttributeName' => 'contacts', 'relationModelId' => $contact[0]->id, 'relationModuleId' => 'contacts', 'redirectUrl' => 'someRedirect'));
     $this->setPostArray(array('Opportunity' => array('name' => 'mySuperNewOpportunity', 'description' => '456765421', 'closeDate' => '11/1/11', 'amount' => array('value' => '545', 'currency' => array('id' => $currencies[0]->id)), 'stage' => array('value' => 'Negotiating'))));
     $this->runControllerWithRedirectExceptionAndGetContent('opportunities/default/createFromRelation');
     $opportunities = Opportunity::getByName('mySuperNewOpportunity');
     $this->assertEquals(1, count($opportunities));
     $this->assertTrue($opportunities[0]->id > 0);
     $this->assertTrue($opportunities[0]->owner == $super);
     $this->assertEquals(1, $opportunities[0]->contacts->count());
     $this->assertTrue($opportunities[0]->contacts[0] == $contact[0]);
     $this->assertEquals('456765421', $opportunities[0]->description);
     $this->assertEquals('545', $opportunities[0]->amount->value);
     $this->assertEquals('2011-11-01', $opportunities[0]->closeDate);
     $this->assertEquals('Negotiating', $opportunities[0]->stage->value);
     $opportunities = Opportunity::getAll();
     $this->assertEquals(14, count($opportunities));
     //todo: test save with account.
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:45,代码来源:OpportunitiesSuperUserWalkthroughTest.php


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