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


PHP Contact::getById方法代码示例

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


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

示例1: testUnlinkContactForAccount

 public function testUnlinkContactForAccount()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $simpleUser = User::getByUsername('simpleUser');
     Yii::app()->user->userModel = $simpleUser;
     $simpleUser->setRight('AccountsModule', AccountsModule::RIGHT_ACCESS_ACCOUNTS);
     $simpleUser->setRight('AccountsModule', AccountsModule::RIGHT_CREATE_ACCOUNTS);
     $simpleUser->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
     $simpleUser->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
     $this->assertTrue($simpleUser->save());
     $account = AccountTestHelper::createAccountByNameForOwner('simpleUserAccount', $simpleUser);
     $contact = ContactTestHelper::createContactWithAccountByNameForOwner('simpleUserContact', $simpleUser, $account);
     $accounts = Account::getAll();
     $this->assertEquals(1, count($accounts));
     $contacts = Contact::getAll();
     $this->assertEquals(1, count($contacts));
     $superAccountId = self::getModelIdByModelNameAndName('Account', 'simpleUserAccount');
     $this->setGetArray(array('id' => $superAccountId));
     $this->resetPostArray();
     $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
     $contactId = self::getModelIdByModelNameAndName('Contact', 'simpleUserContact simpleUserContactson');
     //unlinking the contact
     $this->setGetArray(array('id' => $contactId, 'relationModelClassName' => 'Account', 'relationModelId' => $superAccountId, 'relationModelRelationName' => 'contacts'));
     $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/unlink', true);
     $accounts = Account::getAll();
     $this->assertEquals(1, count($accounts));
     $contacts = Contact::getAll();
     $contactId = $contacts[0]->id;
     $contacts[0]->forget();
     $contact = Contact::getById($contactId);
     $this->assertTrue($contact->account->id < 0);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:AccountsRegularUserUnlinkWalkthroughTest.php

示例2: resolveContactByPostRecipientData

 protected function resolveContactByPostRecipientData(array $recipientData)
 {
     if (isset($recipientData['contactId'])) {
         return Contact::getById(intval($recipientData['contactId']));
     }
     return null;
 }
开发者ID:KulturedKitsch,项目名称:kulturedkitsch.info,代码行数:7,代码来源:SendTestEmailUtil.php

示例3: generateCampaignItems

 protected static function generateCampaignItems($campaign, $pageSize)
 {
     if ($pageSize == null) {
         $pageSize = self::DEFAULT_CAMPAIGNITEMS_TO_CREATE_PAGE_SIZE;
     }
     $contacts = array();
     $quote = DatabaseCompatibilityUtil::getQuote();
     $marketingListMemberTableName = RedBeanModel::getTableName('MarketingListMember');
     $campaignItemTableName = RedBeanModel::getTableName('CampaignItem');
     $sql = "select {$quote}{$marketingListMemberTableName}{$quote}.{$quote}contact_id{$quote} from {$quote}{$marketingListMemberTableName}{$quote}";
     // Not Coding Standard
     $sql .= "left join {$quote}{$campaignItemTableName}{$quote} on ";
     $sql .= "{$quote}{$campaignItemTableName}{$quote}.{$quote}contact_id{$quote} ";
     $sql .= "= {$quote}{$marketingListMemberTableName}{$quote}.{$quote}contact_id{$quote}";
     $sql .= "AND {$quote}{$campaignItemTableName}{$quote}.{$quote}campaign_id{$quote} = " . $campaign->id . " ";
     $sql .= "where {$quote}{$marketingListMemberTableName}{$quote}.{$quote}marketinglist_id{$quote} = " . $campaign->marketingList->id;
     $sql .= " and {$quote}{$campaignItemTableName}{$quote}.{$quote}id{$quote} is null limit " . $pageSize;
     $ids = R::getCol($sql);
     foreach ($ids as $contactId) {
         $contacts[] = Contact::getById((int) $contactId);
     }
     if (!empty($contacts)) {
         //todo: if the return value is false, then we might need to catch that since it didn't go well.
         CampaignItem::registerCampaignItemsByCampaign($campaign, $contacts);
         if (count($ids) < $pageSize) {
             return true;
         }
     } else {
         return true;
     }
     return false;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:32,代码来源:CampaignItemsUtil.php

示例4: deleteAction

 public function deleteAction()
 {
     $contactObj = Contact::getById($this->getRequest()->getParam('id'));
     if ($this->getRequest()->isPost()) {
         $contactObj->delete();
         $this->Member->log('Đặt hàng: ' . $contactObj->full_name . '(' . $this->getRequest()->getParam('id') . ')', 'Xóa đơn hàng');
         My_Plugin_Libs::setSplash('Đơn hàng của: <b>' . $contactObj->full_name . '</b> đã xóa khỏi hệ thống.');
         $this->_redirect($this->_helper->url('index', 'contact', 'admin'));
     }
     $this->view->Contact = $contactObj;
 }
开发者ID:hoaitn,项目名称:base-zend,代码行数:11,代码来源:ContactController.php

示例5: actionCreateFromRelation

 public function actionCreateFromRelation($relationAttributeName, $relationModelId, $relationModuleId, $redirectUrl)
 {
     $opportunity = $this->resolveNewModelByRelationInformation(new Opportunity(), $relationAttributeName, (int) $relationModelId, $relationModuleId);
     if ($relationAttributeName == 'contacts') {
         $relationContact = Contact::getById((int) $relationModelId);
         if ($relationContact->account->id > 0) {
             $opportunity->account = $relationContact->account;
         }
     }
     $this->actionCreateByModel($opportunity, $redirectUrl);
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:11,代码来源:DefaultController.php

示例6: testRun

 /**
  * Test sending an email that should go out as a processing that this job would typically do.
  * Also tests that item does not get trashed when deleting the WorkflowMessageInQueue.
  * Also tests that if there is more than one emailmessage against the workflow, that it does not send
  * to all of them
  * @depends testWorkflowMessageInQueueProperlySavesWithoutTrashingRelatedModelItem
  */
 public function testRun()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $emailTemplate = new EmailTemplate();
     $emailTemplate->name = 'the name';
     $emailTemplate->modelClassName = 'Account';
     $emailTemplate->type = 2;
     $emailTemplate->subject = 'subject';
     $emailTemplate->textContent = 'sample text content';
     $saved = $emailTemplate->save();
     $this->assertTrue($saved);
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $model = ContactTestHelper::createContactByNameForOwner('Jason', Yii::app()->user->userModel);
     $model->primaryEmail->emailAddress = 'jason@zurmoland.com';
     $saved = $model->save();
     $this->assertTrue($saved);
     $modelId = $model->id;
     $model->forget();
     $model = Contact::getById($modelId);
     $trigger = array('attributeIndexOrDerivedType' => 'firstName', 'operator' => OperatorRules::TYPE_EQUALS, 'durationInterval' => '333');
     $actions = array(array('type' => ActionForWorkflowForm::TYPE_UPDATE_SELF, ActionForWorkflowForm::ACTION_ATTRIBUTES => array('description' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'some new description'))));
     $emailMessages = array();
     $emailMessages[0]['emailTemplateId'] = $emailTemplate->id;
     $emailMessages[0]['sendFromType'] = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $emailMessages[0]['sendAfterDurationSeconds'] = '0';
     $emailMessages[0][EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS] = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL, 'audienceType' => EmailMessageRecipient::TYPE_TO));
     $emailMessages[1]['emailTemplateId'] = $emailTemplate->id;
     $emailMessages[1]['sendFromType'] = EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
     $emailMessages[1]['sendAfterDurationSeconds'] = '10000';
     $emailMessages[1][EmailMessageForWorkflowForm::EMAIL_MESSAGE_RECIPIENTS] = array(array('type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL, 'audienceType' => EmailMessageRecipient::TYPE_TO));
     $savedWorkflow = new SavedWorkflow();
     $savedWorkflow->name = 'some workflow';
     $savedWorkflow->description = 'description';
     $savedWorkflow->moduleClassName = 'ContactsModule';
     $savedWorkflow->triggerOn = Workflow::TRIGGER_ON_NEW_AND_EXISTING;
     $savedWorkflow->type = Workflow::TYPE_ON_SAVE;
     $data[ComponentForWorkflowForm::TYPE_TRIGGERS] = array($trigger);
     $data[ComponentForWorkflowForm::TYPE_ACTIONS] = $actions;
     $data[ComponentForWorkflowForm::TYPE_EMAIL_MESSAGES] = $emailMessages;
     $savedWorkflow->serializedData = serialize($data);
     $savedWorkflow->isActive = true;
     $saved = $savedWorkflow->save();
     $this->assertTrue($saved);
     WorkflowTestHelper::createExpiredWorkflowMessageInQueue($model, $savedWorkflow, serialize(array($emailMessages[1])));
     RedBeanModelsCache::forgetAll(true);
     //simulates page change, required to confirm Item does not get trashed
     $this->assertEquals(1, count(WorkflowMessageInQueue::getAll()));
     $job = new WorkflowMessageInQueueJob();
     $this->assertTrue($job->run());
     $this->assertEquals(0, count(WorkflowMessageInQueue::getAll()));
     RedBeanModelsCache::forgetAll(true);
     //simulates page change, required to confirm Item does not get trashed
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:61,代码来源:WorkflowMessageInQueueJobTest.php

示例7: deleteAction

 public function deleteAction()
 {
     $contactObj = Contact::getById($this->getRequest()->getParam('id'));
     if ($contactObj) {
         if ($this->getRequest()->isPost()) {
             $contactObj->delete();
             $this->Member->log('Delete: ' . $contactObj->contact_first_name . " " . $contactObj->contact_last_name . '(' . $this->getRequest()->getParam('id') . ')', 'Contact');
             My_Plugin_Libs::setSplash('Contact by: <b>' . $contactObj->contact_first_name . " " . $contactObj->contact_last_name . '</b> have been delete.');
             $this->_redirect($this->_helper->url('index', 'contact', 'admin'));
         }
         $this->view->Contact = $contactObj;
     }
 }
开发者ID:hoaitn,项目名称:base-zend,代码行数:13,代码来源:ContactController.php

示例8: testSuperUserCreateMessageAndViewDetails

 public function testSuperUserCreateMessageAndViewDetails()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     Yii::app()->emailHelper->outboundHost = 'temporaryForTesting';
     $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact superContactson');
     $contact = Contact::getById($superContactId);
     //Just going to compose without coming from any specific record
     $this->resetGetArray();
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/createEmailMessage');
     //Go to compose without the email address set but the contact set
     $this->setGetArray(array('relatedId' => $superContactId, 'relatedModelClassName' => 'Contact'));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/createEmailMessage');
     //Go to compose with the email address set and the contact set
     $this->setGetArray(array('toAddress' => 'test@contact.com', 'relatedId' => $superContactId, 'relatedModelClassName' => 'Contact'));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/createEmailMessage');
     //confirm there are no email messages currently
     $this->assertEquals(0, EmailMessage::getCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     //Test create email with invalid form
     $createEmailMessageFormData = array('recipientsData' => array('to' => 'test@contact.com'), 'subject' => '', 'content' => '');
     $this->setPostArray(array('ajax' => 'edit-form', 'CreateEmailMessageForm' => $createEmailMessageFormData));
     $content = $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/createEmailMessage');
     //Confirm that error messages are displayed
     $this->assertContains(Zurmo::t('emailMessagesModule', 'Subject cannot be blank.'), $content);
     //Confirm that no email messages was sent
     $this->assertEquals(0, EmailMessage::getCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     //Validate form
     $createEmailMessageFormData = array('recipientsData' => array('to' => 'testNewAddress@contact.com'), 'subject' => 'test subject', 'content' => array('htmlContent' => '<p>html body content</p>'));
     $this->setGetArray(array('toAddress' => 'test@contact.com', 'relatedId' => $superContactId, 'relatedModelClassName' => 'Contact'));
     $this->setPostArray(array('ajax' => 'edit-form', 'CreateEmailMessageForm' => $createEmailMessageFormData));
     $this->runControllerWithExitExceptionAndGetContent('emailMessages/default/createEmailMessage');
     //create email message
     $this->setGetArray(array('toAddress' => 'test@contact.com', 'relatedId' => $superContactId, 'relatedModelClassName' => 'Contact'));
     $this->setPostArray(array('CreateEmailMessageForm' => $createEmailMessageFormData));
     $this->runControllerWithNoExceptionsAndGetContent('emailMessages/default/createEmailMessage', true);
     //confirm there is one email
     $this->assertEquals(1, EmailMessage::getCount());
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     //To address must be the one in postArray
     $emailMessages = EmailMessage::getAll();
     $this->assertEquals('testNewAddress@contact.com', $emailMessages[0]->recipients[0]->toAddress);
     //Test the default permission was setted
     $everyoneGroup = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $explicitReadWriteModelPermissions = ExplicitReadWriteModelPermissionsUtil::makeBySecurableItem($emailMessages[0]);
     $readWritePermitables = $explicitReadWriteModelPermissions->getReadWritePermitables();
     $this->assertEquals($everyoneGroup, $readWritePermitables[$everyoneGroup->getClassId('Permitable')]);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:51,代码来源:EmailMessagesSuperUserWalkthroughTest.php

示例9: testKanbanViewForContactDetails

 public function testKanbanViewForContactDetails()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact superContactson');
     $contact = Contact::getById($superContactId);
     $task = TaskTestHelper::createTaskWithOwnerAndRelatedItem('MyTask', $super, $contact, Task::STATUS_IN_PROGRESS);
     $taskNew = TaskTestHelper::createTaskWithOwnerAndRelatedItem('MyTask New', $super, $contact, Task::STATUS_NEW);
     $this->setGetArray(array('id' => $task->id, 'kanbanBoard' => '1'));
     $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/details');
     $matcher = array('tag' => 'h4', 'ancestor' => array('tag' => 'li', 'id' => 'items_' . $task->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-3'), 'content' => 'MyTask');
     $this->assertTag($matcher, $content);
     $matcher = array('tag' => 'h4', 'ancestor' => array('tag' => 'li', 'id' => 'items_' . $taskNew->id, 'tag' => 'ul', 'id' => 'task-sortable-rows-1'), 'content' => 'MyTask New');
     $this->assertTag($matcher, $content);
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:14,代码来源:ContactsSuperUserKanbanBoardWalkthroughTest.php

示例10: testSuperUserAllDefaultControllerActions

 public function testSuperUserAllDefaultControllerActions()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $superAccountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
     $superAccountId2 = self::getModelIdByModelNameAndName('Account', 'superAccount2');
     $superContactId = self::getModelIdByModelNameAndName('Contact', 'superContact superContactson');
     $account = Account::getById($superAccountId);
     $account2 = Account::getById($superAccountId2);
     $contact = Contact::getById($superContactId);
     //confirm no existing activities exist
     $activities = Activity::getAll();
     $this->assertEquals(0, count($activities));
     //Test just going to the create from relation view.
     $this->setGetArray(array('relationAttributeName' => 'Account', 'relationModelId' => $superAccountId, 'relationModuleId' => 'accounts', 'redirectUrl' => 'someRedirect'));
     $this->runControllerWithNoExceptionsAndGetContent('tasks/default/modalCreateFromRelation');
     //add related task for account using createFromRelation action
     $activityItemPostData = array('Account' => array('id' => $superAccountId));
     $this->setGetArray(array('relationAttributeName' => 'Account', 'relationModelId' => $superAccountId, 'relationModuleId' => 'accounts', 'redirectUrl' => 'someRedirect'));
     $this->setPostArray(array('ActivityItemForm' => $activityItemPostData, 'Task' => array('name' => 'myTask')));
     $this->runControllerWithNoExceptionsAndGetContent('tasks/default/modalSaveFromRelation');
     //now test that the new task exists, and is related to the account.
     $tasks = Task::getAll();
     $this->assertEquals(1, count($tasks));
     $this->assertEquals('myTask', $tasks[0]->name);
     $this->assertEquals(1, $tasks[0]->activityItems->count());
     $activityItem1 = $tasks[0]->activityItems->offsetGet(0);
     $this->assertEquals($account, $activityItem1);
     //test viewing the existing task in a details view
     $this->setGetArray(array('id' => $tasks[0]->id));
     $this->resetPostArray();
     $this->runControllerWithNoExceptionsAndGetContent('tasks/default/modalDetails');
     //test submitting the task on change
     $this->setGetArray(array('id' => $tasks[0]->id));
     $this->setPostArray(array('Task' => array('name' => 'myTask', 'status' => Task::STATUS_IN_PROGRESS)));
     $this->runControllerWithNoExceptionsAndGetContent('tasks/default/modalDetails');
     //Test just going to the copy from relation
     $this->setGetArray(array('relationAttributeName' => 'Account', 'relationModelId' => $superAccountId, 'relationModuleId' => 'accounts', 'id' => $tasks[0]->id));
     $this->runControllerWithNoExceptionsAndGetContent('tasks/default/modalCopyFromRelation');
     $tasks = Task::getAll();
     $this->assertEquals(2, count($tasks));
     $this->assertEquals('myTask', $tasks[1]->name);
     $this->assertEquals(1, $tasks[1]->activityItems->count());
     //test removing a task.
     $this->setGetArray(array('id' => $tasks[0]->id));
     $this->resetPostArray();
     $this->runControllerWithNoExceptionsAndGetContent('tasks/default/delete', true);
     //Confirm no more tasks exist.
     $tasks = Task::getAll();
     $this->assertEquals(1, count($tasks));
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:50,代码来源:TasksSuperUserWalkthroughTest.php

示例11: validateSelectedContact

 public function validateSelectedContact($attribute, $params)
 {
     if ($this->selectContactOrEmailRadioButton == 1) {
         return true;
     }
     $contactId = $this->selectContactOrLeadSearchBox;
     if (!empty($contactId)) {
         try {
             $contact = Contact::getById((int) $contactId);
             if (empty($contact->primaryEmail->emailAddress)) {
                 $this->addError($attribute, Zurmo::t('MarketingModule', 'Selected contact does not have a valid primary email address.'));
                 return false;
             }
             return true;
         } catch (NotFoundException $e) {
         }
     }
     $this->addError($attribute, Zurmo::t('MarketingModule', 'Please select a valid contact.'));
     return true;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:20,代码来源:SendTestEmailForm.php

示例12: testUnlinkContactForAccount

 public function testUnlinkContactForAccount()
 {
     $accounts = Account::getAll();
     $this->assertEquals(1, count($accounts));
     $contacts = Contact::getAll();
     $this->assertEquals(2, count($contacts));
     $superAccountId = self::getModelIdByModelNameAndName('Account', 'superAccount');
     $this->setGetArray(array('id' => $superAccountId));
     $this->resetPostArray();
     $this->runControllerWithNoExceptionsAndGetContent('accounts/default/details');
     $contactId = self::getModelIdByModelNameAndName('Contact', 'superContact superContactson');
     //unlinking the contact
     $this->setGetArray(array('id' => $contactId, 'relationModelClassName' => 'Account', 'relationModelId' => $superAccountId, 'relationModelRelationName' => 'contacts'));
     $content = $this->runControllerWithNoExceptionsAndGetContent('contacts/default/unlink', true);
     $accounts = Account::getAll();
     $this->assertEquals(1, count($accounts));
     $contacts = Contact::getAll();
     $contactId = $contacts[0]->id;
     $contacts[0]->forget();
     $contact = Contact::getById($contactId);
     $this->assertTrue($contact->account->id < 0);
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:22,代码来源:AccountsSuperUserUnlinkWalkthroughTest.php

示例13: generateCampaignItems

 protected static function generateCampaignItems($campaign, $pageSize)
 {
     if ($pageSize == null) {
         $pageSize = self::DEFAULT_CAMPAIGNITEMS_TO_CREATE_PAGE_SIZE;
     }
     $contacts = array();
     $quote = DatabaseCompatibilityUtil::getQuote();
     $sql = "select {$quote}marketinglistmember{$quote}.{$quote}contact_id{$quote} from {$quote}marketinglistmember{$quote}\n                    left join {$quote}campaignitem{$quote} on {$quote}campaignitem{$quote}.{$quote}contact_id{$quote} " . "= {$quote}marketinglistmember{$quote}.{$quote}contact_id{$quote} " . "AND {$quote}campaignitem{$quote}.{$quote}campaign_id{$quote} = " . $campaign->id . " where {$quote}marketinglistmember{$quote}.{$quote}marketinglist_id{$quote} = " . $campaign->marketingList->id . " and {$quote}campaignitem{$quote}.{$quote}id{$quote} IS NULL limit " . $pageSize;
     $ids = R::getCol($sql);
     foreach ($ids as $contactId) {
         $contacts[] = Contact::getById((int) $contactId);
     }
     if (!empty($contacts)) {
         //todo: if the return value is false, then we might need to catch that since it didn't go well.
         CampaignItem::registerCampaignItemsByCampaign($campaign, $contacts);
         if (count($ids) < $pageSize) {
             return true;
         }
     } else {
         return true;
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:22,代码来源:CampaignItemsUtil.php

示例14: testGenerateCampaignItemsForDueCampaignsWithCustomBatchSize

 /**
  * @depends testGenerateCampaignItemsForDueCampaigns
  */
 public function testGenerateCampaignItemsForDueCampaignsWithCustomBatchSize()
 {
     $contactIds = array();
     $marketingListIds = array();
     $campaignIds = array();
     for ($index = 6; $index < 9; $index++) {
         $contact = ContactTestHelper::createContactByNameForOwner('campaignContact 0' . $index, $this->user);
         $contactIds[] = $contact->id;
         $contact->forgetAll();
     }
     for ($index = 8; $index < 12; $index++) {
         $suffix = $index;
         if ($index < 10) {
             $suffix = "0{$suffix}";
         }
         $marketingList = MarketingListTestHelper::createMarketingListByName('marketingList ' . $suffix);
         $marketingListId = $marketingList->id;
         $marketingListIds[] = $marketingListId;
         foreach ($contactIds as $contactId) {
             $contact = Contact::getById($contactId);
             $unsubscribed = rand(10, 20) % 2;
             MarketingListMemberTestHelper::createMarketingListMember($unsubscribed, $marketingList, $contact);
         }
         $marketingList->forgetAll();
         $marketingList = MarketingList::getById($marketingListId);
         $campaignSuffix = substr($marketingList->name, -2);
         $campaign = CampaignTestHelper::createCampaign('campaign ' . $campaignSuffix, 'subject ' . $campaignSuffix, 'text ' . $campaignSuffix, 'html ' . $campaignSuffix, null, null, null, null, null, null, $marketingList);
         $this->assertNotNull($campaign);
         $campaignIds[] = $campaign->id;
         $campaign->forgetAll();
     }
     foreach ($campaignIds as $campaignId) {
         $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId);
         $this->assertEmpty($campaignItems);
     }
     $this->assertTrue(CampaignItemsUtil::generateCampaignItemsForDueCampaigns(5));
     foreach ($campaignIds as $index => $campaignId) {
         $campaign = Campaign::getById($campaignId);
         $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId);
         if ($index === 0) {
             $expectedCount = AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize();
             $memberCount = count($campaign->marketingList->marketingListMembers);
             if ($memberCount < $expectedCount) {
                 $expectedCount = $memberCount;
             }
             $this->assertNotEmpty($campaignItems);
             $this->assertCount($expectedCount, $campaignItems);
             $this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status);
         } else {
             $this->assertEmpty($campaignItems);
             $this->assertEquals(Campaign::STATUS_ACTIVE, $campaign->status);
         }
     }
     $this->assertTrue(CampaignItemsUtil::generateCampaignItemsForDueCampaigns());
     foreach ($campaignIds as $index => $campaignId) {
         $campaign = Campaign::getById($campaignId);
         $campaignItems = CampaignItem::getByProcessedAndCampaignId(0, $campaignId);
         if ($index < 2) {
             $expectedCount = AutoresponderOrCampaignBatchSizeConfigUtil::getBatchSize();
             $memberCount = count($campaign->marketingList->marketingListMembers);
             if ($memberCount < $expectedCount) {
                 $expectedCount = $memberCount;
             }
             $this->assertNotEmpty($campaignItems);
             $this->assertCount($expectedCount, $campaignItems);
             $this->assertEquals(Campaign::STATUS_PROCESSING, $campaign->status);
         } else {
             $this->assertEmpty($campaignItems);
             $this->assertEquals(Campaign::STATUS_ACTIVE, $campaign->status);
         }
     }
     // TODO: @Shoaibi: Medium: Add tests for the other campaign type.
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:76,代码来源:CampaignItemsUtilTest.php

示例15: testMassDeleteActionsForSelectedIds

 /**
  * @deletes selected leads.
  */
 public function testMassDeleteActionsForSelectedIds()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $leads = Contact::getAll();
     $this->assertEquals(16, count($leads));
     $superLeadId = self::getModelIdByModelNameAndName('Contact', 'superLead');
     $superLeadId2 = self::getModelIdByModelNameAndName('Contact', 'superLead2 superLead2son');
     $superLeadId3 = self::getModelIdByModelNameAndName('Contact', 'superLead3 superLead3son');
     $superLeadId4 = self::getModelIdByModelNameAndName('Contact', 'myNewLead myNewLeadson');
     $superLeadId5 = self::getModelIdByModelNameAndName('Contact', 'superLead5 superLead5son');
     $superLeadId6 = self::getModelIdByModelNameAndName('Contact', 'superLead6 superLead6son');
     $superLeadId7 = self::getModelIdByModelNameAndName('Contact', 'superLead7 superLead7son');
     $superLeadId8 = self::getModelIdByModelNameAndName('Contact', 'superLead8 superLead8son');
     $superLeadId9 = self::getModelIdByModelNameAndName('Contact', 'superLead9 superLead9son');
     $superLeadId10 = self::getModelIdByModelNameAndName('Contact', 'superLead10 superLead10son');
     $superLeadId11 = self::getModelIdByModelNameAndName('Contact', 'superLead11 superLead11son');
     $superLeadId12 = self::getModelIdByModelNameAndName('Contact', 'superLead12 superLead12son');
     $superLeadId13 = self::getModelIdByModelNameAndName('Contact', 'myClonedLead myClonedLeadson');
     //Load Model MassDelete Views.
     //MassDelete view for single selected ids
     $this->setGetArray(array('selectedIds' => '5,6,7,8,9', 'selectAll' => ''));
     // Not Coding Standard
     $this->resetPostArray();
     $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massDelete');
     $this->assertFalse(strpos($content, '<strong>5</strong>&#160;Leads selected for removal') === false);
     //MassDelete view for all result selected ids
     $this->setGetArray(array('selectAll' => '1'));
     $this->resetPostArray();
     $content = $this->runControllerWithNoExceptionsAndGetContent('leads/default/massDelete');
     $this->assertFalse(strpos($content, '<strong>12</strong>&#160;Leads selected for removal') === false);
     //MassDelete for selected Record Count
     $leads = Contact::getAll();
     $this->assertEquals(16, count($leads));
     //MassDelete for selected ids for paged scenario
     $lead1 = Contact::getById($superLeadId);
     $lead2 = Contact::getById($superLeadId2);
     $lead3 = Contact::getById($superLeadId3);
     $lead4 = Contact::getById($superLeadId4);
     $lead5 = Contact::getById($superLeadId5);
     $lead6 = Contact::getById($superLeadId6);
     $pageSize = Yii::app()->pagination->getForCurrentUserByType('massDeleteProgressPageSize');
     $this->assertEquals(5, $pageSize);
     //MassDelete for selected ids for page 1
     $this->setGetArray(array('selectedIds' => $superLeadId . ',' . $superLeadId2 . ',' . $superLeadId3 . ',' . $superLeadId4 . ',' . $superLeadId5 . ',' . $superLeadId6, 'selectAll' => '', 'massDelete' => '', 'Contact_page' => 1));
     $this->setPostArray(array('selectedRecordCount' => 6));
     $this->runControllerWithExitExceptionAndGetContent('leads/default/massDelete');
     //MassDelete for selected Record Count
     $leads = Contact::getAll();
     $this->assertEquals(11, count($leads));
     //MassDelete for selected ids for page 2
     $this->setGetArray(array('selectedIds' => $superLeadId . ',' . $superLeadId2 . ',' . $superLeadId3 . ',' . $superLeadId4 . ',' . $superLeadId5 . ',' . $superLeadId6 . ',' . $superLeadId13, 'selectAll' => '', 'massDelete' => '', 'Contact_page' => 2));
     $this->setPostArray(array('selectedRecordCount' => 7));
     $this->runControllerWithNoExceptionsAndGetContent('leads/default/massDeleteProgress');
     //MassDelete for selected Record Count
     $leads = Contact::getAll();
     $this->assertEquals(9, count($leads));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:60,代码来源:LeadsSuperUserWalkthroughTest.php


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