本文整理汇总了PHP中Contact::getCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Contact::getCount方法的具体用法?PHP Contact::getCount怎么用?PHP Contact::getCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contact
的用法示例。
在下文中一共展示了Contact::getCount方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSuperUserThatContactsAndLeadsShowZeroModelUserInterfaceCorrectly
public function testSuperUserThatContactsAndLeadsShowZeroModelUserInterfaceCorrectly()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$this->assertEquals(0, Contact::getCount());
//At this point the zero model ui should show up for contacts and leads
$content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/list');
$this->assertContains('Arthur Conan', $content);
$content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/list');
$this->assertContains('Thomas Paine', $content);
$contact = ContactTestHelper::createContactByNameForOwner('Jimmy', $super);
//At this point leads should still show the zero model message
$content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/list');
$this->assertNotContains('Arthur Conan', $content);
$content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/list');
$this->assertContains('Thomas Paine', $content);
$this->assertTrue($contact->delete());
$this->assertEquals(0, Contact::getCount());
//Create lead.
$lead = LeadTestHelper::createLeadByNameForOwner('Jammy', $super);
//At this point contacts should still show the zero model message
$content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/list');
$this->assertContains('Arthur Conan', $content);
$content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/list');
$this->assertNotContains('Thomas Paine', $content);
}
示例2: testLoad
public function testLoad()
{
$this->assertEquals(2, Group::getCount());
$this->assertEquals(0, Role::getCount());
$this->assertEquals(0, Account::getCount());
$this->assertEquals(0, Contact::getCount());
$this->assertEquals(0, Opportunity::getCount());
$this->assertEquals(0, Meeting::getCount());
$this->assertEquals(0, Note::getCount());
$this->assertEquals(0, Task::getCount());
$this->assertEquals(1, User::getCount());
$this->assertEquals(0, ProductCatalog::getCount());
$this->assertEquals(0, ProductCategory::getCount());
$this->assertEquals(0, ProductTemplate::getCount());
$this->assertEquals(0, Product::getCount());
$messageLogger = new MessageLogger();
DemoDataUtil::unsetLoadedModules();
DemoDataUtil::load($messageLogger, 3);
$this->assertEquals(8, Group::getCount());
$this->assertEquals(3, Role::getCount());
$this->assertEquals(3, Account::getCount());
$this->assertEquals(16, Contact::getCount());
$this->assertEquals(6, Opportunity::getCount());
$this->assertEquals(18, Meeting::getCount());
$this->assertEquals(12, Note::getCount());
$this->assertEquals(9, Task::getCount());
$this->assertEquals(10, User::getCount());
$this->assertEquals(1, ProductCatalog::getCount());
$this->assertEquals(6, ProductCategory::getCount());
$this->assertEquals(32, ProductTemplate::getCount());
$this->assertEquals(59, Product::getCount());
}
示例3: populateValidMarketingListMember
public static function populateValidMarketingListMember($unsubscribed = 0, $marketingList = null, $contact = null, $iterations = 0)
{
// following is a quick hack to ensure that we always try to save a validated marketing list member
// why do we need it? because we are using random contacts and random marketing lists above
// give the number of available marketinglists/contacts we might have a member that already exists
$marketingListMember = static::populateMarketingListMember($unsubscribed, $marketingList, $contact);
$mustReturnValidMember = !isset($marketingList, $contact);
$maxIterations = MarketingList::getCount() * Contact::getCount();
if ($mustReturnValidMember) {
if (!$marketingListMember->validate()) {
if ($iterations == $maxIterations) {
var_dump("Tried {$maxIterations} iterations to populate a valid MarketingListMember. Bailing out.");
return $marketingListMember;
}
$iterations++;
$marketingListMember = static::populateValidMarketingListMember($unsubscribed, null, null, $iterations);
}
}
return $marketingListMember;
}
示例4: testRunWithCampaignPausedAfterAllItemsGeneratedAndThenUnpaused
public function testRunWithCampaignPausedAfterAllItemsGeneratedAndThenUnpaused()
{
// Cleanup
Campaign::deleteAll();
$this->assertEquals(0, Campaign::getCount());
$this->assertEquals(0, CampaignItem::getCount());
$this->assertEquals(0, CampaignItemActivity::getCount());
MarketingList::deleteAll();
$this->assertEquals(0, MarketingList::getCount());
$this->assertEquals(0, MarketingListMember::getCount());
EmailMessage::deleteAll();
$this->assertEquals(0, EmailMessage::getCount());
$this->assertEquals(0, EmailMessageContent::getCount());
$this->assertEquals(0, EmailMessageSender::getCount());
$this->assertEquals(0, EmailMessageRecipient::getCount());
Contact::deleteAll();
$this->assertEquals(0, Contact::getCount());
// setup an email address for contacts
$email = new Email();
$email->emailAddress = 'demo@zurmo.com';
// create a marketing list with 5 members
$marketingList = MarketingListTestHelper::createMarketingListByName('marketingList 05');
$marketingListId = $marketingList->id;
for ($i = 1; $i <= 5; $i++) {
$contact = ContactTestHelper::createContactByNameForOwner('campaignContact 0' . $i, $this->user);
$contact->primaryEmail = $email;
$this->assertTrue($contact->save());
MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList, $contact);
}
$marketingList->forgetAll();
// create a due campaign with that marketing list
$campaign = CampaignTestHelper::createCampaign('campaign 04', 'subject', 'text Content', 'Html Content', null, null, null, null, null, null, MarketingList::getById($marketingListId));
$campaignId = $campaign->id;
/*
* Run 1:
* CampaignGenerateDueCampaignItemsJob
* status == processing
* items generated but unprocessed
*
* CampaignQueueMessagesInOutboxJob
* status == processing
* items processed with email messages generated and queued
*
* ProcessOutboundEmailJob
* status == processing
* email items attempted to be sent
*
* Run 2:
* Pause the campaign
* items are processed and still present
*
* Unpause the campaign
* status == active
* items are processed and still present
*
* CampaignGenerateDueCampaignItemsJob
* status == processing
* ensure all items are present and processed
*
* CampaignQueueMessagesInOutboxJob
* status == processing
* ensure all items are present and processed
* ensure all email messages are present with correct folder type
*
* ProcessOutboundEmailJob
* ensure all email messages are present with correct folder type
* status == processing
*
*
* Run 3:
* Mark Campaign as Completed
* status == completed
*/
// we have to do this to ensure when we retrieve the data status is updated from db.
$campaign->forgetAll();
$this->assertEmpty(CampaignItem::getAll());
// Run 1 starts here
// Run CampaignGenerateDueCampaignItemsJob
$job = new CampaignGenerateDueCampaignItemsJob();
$this->assertTrue($job->run());
$campaign = Campaign::getById($campaignId);
// ensure status is processing
$this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status);
// ensure 5 campaign items have been generated
$this->assertEquals(5, CampaignItem::getCount());
// ensure all 5 campaign items are unprocessed
$campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId);
$this->assertNotEmpty($campaignItems);
$this->assertCount(5, $campaignItems);
// Run CampaignQueueMessagesInOutboxJob
$job = new CampaignQueueMessagesInOutboxJob();
$this->assertTrue($job->run());
// Ensure campaign status
$campaign = Campaign::getById($campaignId);
$this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status);
// ensure all 5 campaign items are processed
$campaignItems = CampaignItem::getByProcessedAndCampaignId(1, $campaignId);
$this->assertNotEmpty($campaignItems);
$this->assertCount(5, $campaignItems);
// Ensure 5 new email messages
//.........这里部分代码省略.........
示例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')]);
}
示例6: testRemoveAll
/**
* @depends testRemoveDoesntDeleteRelatedModels
*/
public function testRemoveAll()
{
Yii::app()->user->userModel = User::getByUsername('super');
$accounts = Account::getByName('Wibble Corp');
$this->assertEquals(1, count($accounts));
$account = $accounts[0];
$this->assertEquals(self::CONTACTS, Contact::getCount());
$this->assertEquals(self::CONTACTS - 1, $account->contacts->count());
$account->contacts->removeAll();
$this->assertEquals(0, $account->contacts->count());
$account->forget();
unset($account);
// None of the contacts should be removed since they are not owned by the account.
$this->assertEquals(self::CONTACTS, Contact::getCount());
}
示例7: testSubscribeContactsForReportType
public function testSubscribeContactsForReportType()
{
$type = 'report';
$report = SavedReportTestHelper::makeSimpleContactRowsAndColumnsReport();
$marketingList = MarketingListTestHelper::createMarketingListByName('MarketingList5', 'MarketingList Description5');
$marketingListId = $marketingList->id;
$contactCount = Contact::getCount();
$this->assertNotNull($report);
$this->setGetArray(array('marketingListId' => $marketingListId, 'id' => $report->id, 'type' => $type));
$content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts');
$contentArray = CJSON::decode($content);
$this->assertNotEmpty($contentArray);
$this->assertArrayHasKey('type', $contentArray);
$this->assertArrayHasKey('message', $contentArray);
$this->assertEquals($contactCount . ' subscribed.', $contentArray['message']);
$this->assertEquals('message', $contentArray['type']);
$content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts');
$contentArray = CJSON::decode($content);
$this->assertNotEmpty($contentArray);
$this->assertArrayHasKey('type', $contentArray);
$this->assertArrayHasKey('message', $contentArray);
$this->assertEquals('0 subscribed. ' . $contactCount . ' skipped, already in the list.', $contentArray['message']);
$this->assertEquals('message', $contentArray['type']);
Yii::app()->pagination->setForCurrentUserByType('reportResultsListPageSize', 1);
$this->setGetArray(array('marketingListId' => $marketingListId, 'id' => $report->id, 'type' => $type, 'page' => 2));
$content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts');
$contentArray = CJSON::decode($content);
$percent = round(2 / $contactCount * 100, 0);
// Not Coding Standard
$this->assertNotEmpty($contentArray);
$this->assertArrayHasKey('type', $contentArray);
$this->assertArrayHasKey('message', $contentArray);
$this->assertEquals("Processing: {$percent} % complete", $contentArray['message']);
$this->assertEquals('message', $contentArray['type']);
$this->assertEquals(3, $contentArray['nextPage']);
$this->assertEquals(0, $contentArray['subscribedCount']);
$this->assertEquals(1, $contentArray['skippedCount']);
$this->setGetArray(array('marketingListId' => $marketingListId, 'id' => $report->id, 'type' => $type, 'page' => $contactCount, 'skippedCount' => $contactCount - 1, 'subscribedCount' => 0));
$content = $this->runControllerWithNoExceptionsAndGetContent('marketingLists/defaultPortlet/subscribeContacts');
$contentArray = CJSON::decode($content);
$this->assertNotEmpty($contentArray);
$this->assertArrayHasKey('type', $contentArray);
$this->assertArrayHasKey('message', $contentArray);
$this->assertEquals("0 subscribed. {$contactCount} skipped, already in the list.", $contentArray['message']);
$this->assertEquals('message', $contentArray['type']);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:46,代码来源:MarketingListDefaultPortletControllerSuperUserWalkthroughTest.php
示例8: testSubscribeContactsForReportTypeFromPortletController
public function testSubscribeContactsForReportTypeFromPortletController()
{
$type = 'report';
$report = SavedReportTestHelper::makeSimpleContactRowsAndColumnsReport();
$this->assertNotNull($report);
$contactCount = Contact::getCount();
$this->setGetArray(array('marketingListId' => static::$marketingList->id, 'id' => $report->id, 'type' => $type));
$content = $this->runControllerWithNoExceptionsAndGetContent($this->portletSubscribeContactsUrl);
$contentArray = CJSON::decode($content);
$this->assertNotEmpty($contentArray);
$this->assertArrayHasKey('type', $contentArray);
$this->assertArrayHasKey('message', $contentArray);
$this->assertEquals('0 subscribed. ' . $contactCount . ' skipped, already in the list.', $contentArray['message']);
$this->assertEquals('message', $contentArray['type']);
$this->assertEquals(1, MarketingListMember::getCount());
}
示例9: testMassSubscribeActionsForSelectedIds
public function testMassSubscribeActionsForSelectedIds()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$contactsCount = Contact::getCount();
$superContactId1 = ContactTestHelper::createContactByNameForOwner('superContact1', $super);
$superContactId2 = ContactTestHelper::createContactByNameForOwner('superContact2', $super);
$superContactId3 = ContactTestHelper::createContactByNameForOwner('superContact3', $super);
$superContactId4 = ContactTestHelper::createContactByNameForOwner('superContact4', $super);
$superContactId5 = ContactTestHelper::createContactByNameForOwner('superContact5', $super);
$superContactId6 = ContactTestHelper::createContactByNameForOwner('superContact6', $super);
$superContactId7 = ContactTestHelper::createContactByNameForOwner('superContact7', $super);
$superContactId8 = ContactTestHelper::createContactByNameForOwner('superContact8', $super);
$superContactId9 = ContactTestHelper::createContactByNameForOwner('superContact9', $super);
$marketingList1 = MarketingListTestHelper::createMarketingListByName('marketingList1');
$marketingList2 = MarketingListTestHelper::createMarketingListByName('marketingList2');
//Load Model MassSubscribe Views.
//MassSubscribe view for single selected ids
$selectedIds = implode(',', array($superContactId1->id, $superContactId4->id));
// Not Coding Standard
$this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => ''));
$this->resetPostArray();
$content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/massSubscribe');
$this->assertContains('<strong>2</strong> Contacts selected for subscription', $content);
//MassSubscribe view for all result selected ids
$this->setGetArray(array('selectAll' => '1'));
$this->resetPostArray();
$content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/massSubscribe');
$this->assertContains('<strong>9</strong> Contacts selected for subscription', $content);
//MassSubscribe with no marketingList selected
//MassSubscribe for selected ids for paged scenario
//MassSubscribe for selected ids for page 1
$pageSize = Yii::app()->pagination->getForCurrentUserByType('massEditProgressPageSize');
$this->assertEquals(5, $pageSize);
$selectedIds = implode(',', array($superContactId1->id, $superContactId2->id, $superContactId3->id, $superContactId5->id, $superContactId6->id, $superContactId8->id, $superContactId9->id));
$this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '', 'massSubscribe' => '', 'Contact_page' => 1));
$this->setPostArray(array('selectedRecordCount' => 7, 'MarketingListMember' => array('marketingList' => array('id' => $marketingList1->id))));
$this->runControllerWithExitExceptionAndGetContent('contacts/default/massSubscribe');
$expectedSubscribedCountAfterFirstRequest = $pageSize;
$actualSubscribedCountAfterFirstRequest = MarketingListMember::getCountByMarketingListIdAndUnsubscribed($marketingList1->id, 0);
$this->assertEquals($expectedSubscribedCountAfterFirstRequest, $actualSubscribedCountAfterFirstRequest);
$this->assertEquals(0, MarketingListMember::getCountByMarketingListIdAndUnsubscribed($marketingList2->id, 0));
//MassSubscribe for selected ids for page 2
$this->setGetArray(array('selectedIds' => $selectedIds, 'selectAll' => '', 'massSubscribe' => '', 'Contact_page' => 2, 'MarketingListMember' => array('marketingList' => array('id' => $marketingList1->id))));
$this->setPostArray(array('selectedRecordCount' => 7, 'MarketingListMember' => array('marketingList' => array('id' => $marketingList1->id))));
$this->runControllerWithNoExceptionsAndGetContent('contacts/default/massSubscribeProgress');
$expectedSubscribedCountAfterSecondRequest = $actualSubscribedCountAfterFirstRequest + (7 - $pageSize);
$actualSubscribedCountAfterSecondRequest = MarketingListMember::getCountByMarketingListIdAndUnsubscribed($marketingList1->id, 0);
$this->assertEquals($expectedSubscribedCountAfterSecondRequest, $actualSubscribedCountAfterSecondRequest);
$this->assertEquals(0, MarketingListMember::getCountByMarketingListIdAndUnsubscribed($marketingList2->id, 0));
}
示例10: 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);
}
示例11: testWorkflowDoesLinkRelatedModelWhenPermissionsIsSetToOwner
public function testWorkflowDoesLinkRelatedModelWhenPermissionsIsSetToOwner()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$contactStates = ContactState::getAll();
$this->assertEquals(0, Contact::getCount());
//Create workflow
$workflow = new Workflow();
$workflow->setDescription('aDescription');
$workflow->setIsActive(true);
$workflow->setOrder(5);
$workflow->setModuleClassName('AccountsModule');
$workflow->setName('myFirstWorkflow');
$workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
$workflow->setType(Workflow::TYPE_ON_SAVE);
$workflow->setTriggersStructure('1');
//Add action
$action = new ActionForWorkflowForm('Account', Workflow::TYPE_ON_SAVE);
$action->type = ActionForWorkflowForm::TYPE_CREATE;
$action->relation = 'contacts';
$attributes = array('lastName' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'smith'), 'firstName' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'john'), 'owner__User' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => Yii::app()->user->userModel->id), 'state' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => $contactStates[0]->id));
$action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes));
$workflow->addAction($action);
//Create the saved Workflow
$savedWorkflow = new SavedWorkflow();
SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
$saved = $savedWorkflow->save();
$this->assertTrue($saved);
$account = new Account();
$account->name = 'myTestAccount';
$account->owner = $super;
$account->save();
RedBeanModel::forgetAll();
$contacts = Contact::getAll();
$this->assertCount(1, $contacts);
$this->assertEquals('myTestAccount', $contacts[0]->account->name);
$this->assertEquals('john smith', strval($account->contacts[0]));
$this->assertTrue($account->contacts[0]->id > 0);
}