本文整理汇总了PHP中ContactTestHelper类的典型用法代码示例。如果您正苦于以下问题:PHP ContactTestHelper类的具体用法?PHP ContactTestHelper怎么用?PHP ContactTestHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ContactTestHelper类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
ZurmoDatabaseCompatibilityUtil::dropStoredFunctionsAndProcedures();
$super = SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = User::getByUsername('super');
$headquarters = AccountTestHelper::createAccountByNameForOwner('Headquarters', $super);
$division1 = AccountTestHelper::createAccountByNameForOwner('Division1', $super);
$division2 = AccountTestHelper::createAccountByNameForOwner('Division2', $super);
$ceo = ContactTestHelper::createContactWithAccountByNameForOwner('ceo', $super, $headquarters);
$div1President = ContactTestHelper::createContactWithAccountByNameForOwner('div1 President', $super, $division1);
$div2President = ContactTestHelper::createContactWithAccountByNameForOwner('div2 President', $super, $division2);
$opportunity = OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('big opp', $super, $headquarters);
$opportunityDiv1 = OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('div1 small opp', $super, $division1);
$opportunityDiv2 = OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('div2 small opp', $super, $division2);
//attach divisions to headquarters
$headquarters->accounts->add($division1);
$headquarters->accounts->add($division2);
assert($headquarters->save());
// Not Coding Standard
//attach opportunities to contacts
$opportunity->contacts->add($ceo);
assert($opportunity->save());
// Not Coding Standard
//Forget models to ensure relations are known on the next retrieval
$headquarters->forget();
$division1->forget();
$division2->forget();
$ceo->forget();
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:30,代码来源:ModelsRollUpTest.php
示例2: 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);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:25,代码来源:ContactsSuperUserZeroModelsWalkthroughTest.php
示例3: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
Yii::app()->user->userModel = User::getByUsername('nobody');
self::$account = AccountTestHelper::createAccountByNameForOwner('superAccount', Yii::app()->user->userModel);
self::$contact = ContactTestHelper::createContactWithAccountByNameForOwner('superContact', Yii::app()->user->userModel, self::$account);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:7,代码来源:AccountContactAffiliationsRegularUserWalkthroughTest.php
示例4: testSuperUserGlobalList
public function testSuperUserGlobalList()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
//Test if actionGlobalList return a list view for all modules
$this->setGetArray(array('MixedModelsSearchForm' => array('anyMixedAttributesScope' => array('All'), 'term' => 't')));
$this->resetPostArray();
$content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/globallist');
$this->assertContains('<div class="cgrid-view type-accounts" id="list-view-accounts">', $content);
$this->assertContains('<div class="cgrid-view type-contacts" id="list-view-contacts">', $content);
$this->assertContains('<div class="cgrid-view type-leads" id="list-view-leads">', $content);
$this->assertContains('<div class="cgrid-view type-opportunities" id="list-view-opportunities">', $content);
//Even if there are results it should return a cgridview with no text
$this->assertNotContains('No results found.', $content);
//Test if actionGlobalList only show the module requested
ContactTestHelper::createContactByNameForOwner('tim', $super);
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
$this->setGetArray(array('MixedModelsSearchForm' => array('term' => 'd'), 'ajax' => 'list-view-accounts'));
$this->resetPostArray();
$content = $this->runControllerWithNoExceptionsAndGetContent('zurmo/default/globallist');
$this->assertContains('id="AccountsForMixedModelsSearchListView"', $content);
$this->assertNotContains('id="ContactsForMixedModelsSearchListView"', $content);
$this->assertNotContains('id="LeadsForMixedModelsSearchListView"', $content);
$this->assertNotContains('id="OpportunitiesForMixedModelsSearchListView">', $content);
//TODO: Should test if the accounts created is shown
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:25,代码来源:ZurmoMixedModelsSearchSuperUserWalkthroughTest.php
示例5: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
//Setup test data owned by the super user.
$account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
AccountTestHelper::createAccountByNameForOwner('superAccount2', $super);
ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
ContactTestHelper::createContactWithAccountByNameForOwner('superContact2', $super, $account);
OpportunityTestHelper::createOpportunityStagesIfDoesNotExist();
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp2', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp3', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp4', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp5', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp6', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp7', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp8', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp9', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp10', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp11', $super, $account);
OpportunityTestHelper::createOpportunityWithAccountByNameForOwner('superOpp12', $super, $account);
//Setup default dashboard.
Dashboard::getByLayoutIdAndUser(Dashboard::DEFAULT_USER_LAYOUT_ID, $super);
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:27,代码来源:OpportunitiesSuperUserWalkthroughTest.php
示例6: resolveEmailMessage
protected function resolveEmailMessage($subject = 'Subject', $textContent = 'My First Message', $htmlContent = 'Some fake HTML content', $fromAddress = '[email protected]', $fromName = 'Zurmo', $toAddress = '[email protected]', $toName = null, $contact = null)
{
if (!isset($contact)) {
$contact = ContactTestHelper::createContactByNameForOwner('emailContact', Yii::app()->user->userModel);
}
$emailMessage = new EmailMessage();
$emailMessage->owner = $contact->owner;
$emailMessage->subject = $subject;
$emailContent = new EmailMessageContent();
$emailContent->textContent = $textContent;
$emailContent->htmlContent = $htmlContent;
$emailMessage->content = $emailContent;
$sender = new EmailMessageSender();
$sender->fromAddress = $fromAddress;
$sender->fromName = $fromName;
$sender->personsOrAccounts->add(Yii::app()->user->userModel);
$emailMessage->sender = $sender;
$recipient = new EmailMessageRecipient();
$recipient->toAddress = $toAddress;
if (!isset($toName)) {
$toName = strval($contact);
}
$recipient->toName = $toName;
$recipient->personsOrAccounts->add($contact);
$recipient->type = EmailMessageRecipient::TYPE_TO;
$emailMessage->recipients->add($recipient);
$emailBox = EmailBoxUtil::getDefaultEmailBoxByUser(Yii::app()->user->userModel);
$emailMessage->folder = EmailFolder::getByBoxAndType($emailBox, EmailFolder::TYPE_OUTBOX);
$saved = $emailMessage->save();
if (!$saved) {
var_dump($emailMessage->getErrors());
throw new FailedToSaveModelException();
}
return $emailMessage;
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:35,代码来源:AutoresponderOrCampaignBaseTest.php
示例7: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$nobody = UserTestHelper::createBasicUser('nobody');
$nobody->setRight('MarketingListsModule', MarketingListsModule::getAccessRight());
$saved = $nobody->save();
static::assertTrue($saved);
Yii::app()->user->userModel = $nobody;
//Setup test data owned by the super user.
$account = AccountTestHelper::createAccountByNameForOwner('nobodyAccount', $nobody);
$marketingList1 = MarketingListTestHelper::createMarketingListByName('MarketingList1', 'MarketingList Description1');
$marketingList2 = MarketingListTestHelper::createMarketingListByName('MarketingList2', 'MarketingList Description2');
for ($i = 0; $i < 17; $i++) {
if ($i % 2) {
$unsubscribed = 0;
} else {
$unsubscribed = 1;
}
$contact1 = ContactTestHelper::createContactWithAccountByNameForOwner('nobodyContact1' . $i, $nobody, $account);
$contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('nobodyContact2' . $i, $nobody, $account);
MarketingListMemberTestHelper::createMarketingListMember($unsubscribed, $marketingList1, $contact1);
MarketingListMemberTestHelper::createMarketingListMember($unsubscribed, $marketingList2, $contact2);
}
AllPermissionsOptimizationUtil::rebuild();
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:26,代码来源:MarketingListMemberControllerRegularUserWalkthroughTest.php
示例8: testCreateAddAndSaveAndRemoveByIndexRelatedModels
public function testCreateAddAndSaveAndRemoveByIndexRelatedModels()
{
Yii::app()->user->userModel = User::getByUsername('super');
$user = UserTestHelper::createBasicUser('Billy');
$account = new Account();
$account->owner = $user;
$account->name = 'Wibble Corp';
$this->assertTrue($account->save());
for ($i = 0; $i < self::CONTACTS; $i++) {
$contact = ContactTestHelper::createContactByNameForOwner('sampleContact' . $i, Yii::app()->user->userModel);
$account->contacts->add($contact);
}
$this->assertTrue($account->save());
$contact = $account->contacts[0];
$this->assertFalse($account->isModified());
$this->assertFalse($contact->isModified());
$this->assertTrue($account->save());
$this->assertFalse($account->isModified());
$this->assertFalse($contact->isModified());
$accountId = $account->id;
unset($account);
$account = Account::getById($accountId);
$this->assertEquals('Wibble Corp', $account->name);
$this->assertEquals(self::CONTACTS, $account->contacts->count());
$this->assertEquals("{$account->contacts->count()} records.", strval($account->contacts));
$contact = $account->contacts[0];
$description = $contact->description;
$contact->description = "this is a contact";
$this->assertTrue($account->isModified());
$this->assertTrue($contact->isModified());
$this->assertTrue($account->save());
$this->assertFalse($account->isModified());
$this->assertFalse($contact->isModified());
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:34,代码来源:RedBeanRelatedModelsTest.php
示例9: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
SecurityTestHelper::createUsers();
$super = User::getByUsername('super');
$super->primaryEmail->emailAddress = '[email protected]';
$saved = $super->save();
if (!$saved) {
throw new FailedToSaveModelException();
}
MarketingListTestHelper::createMarketingListByName('testMarketingList');
$campaign = CampaignTestHelper::createCampaign('testCampaign', 'testSubject', 'testContent', 'testHtmlContent');
$contact = ContactTestHelper::createContactByNameForOwner('test', $super);
$emailMessage = EmailMessageTestHelper::createArchivedUnmatchedSentMessage($super);
$campaignItem = new CampaignItem();
$campaignItem->contact = $contact;
$campaignItem->processed = true;
$campaignItem->campaign = $campaign;
$campaignItem->emailMessage = $emailMessage;
$campaignItem->unrestrictedSave();
if (!$saved) {
throw new FailedToSaveModelException();
}
AllPermissionsOptimizationUtil::rebuild();
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:26,代码来源:CampaignItemSummaryListViewColumnAdapterTest.php
示例10: testCreateAndGetMeetingById
public function testCreateAndGetMeetingById()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$accounts = Account::getByName('anAccount');
$contact1 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $accounts[0]);
$contact2 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact2', $super, $accounts[0]);
$contact3 = ContactTestHelper::createContactWithAccountByNameForOwner('superContact3', $super, $accounts[0]);
$user = UserTestHelper::createBasicUser('Billy');
$startStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
$endStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 11000);
$meeting = new Meeting();
$meeting->name = 'MyMeeting';
$meeting->owner = $user;
$meeting->location = 'my location';
$meeting->category->value = 'Call';
$meeting->startDateTime = $startStamp;
$meeting->endDateTime = $endStamp;
$meeting->description = 'my test description';
$meeting->activityItems->add($accounts[0]);
$meeting->activityItems->add($contact1);
$meeting->activityItems->add($contact2);
$meeting->activityItems->add($contact3);
$this->assertTrue($meeting->save());
$id = $meeting->id;
unset($meeting);
$meeting = Meeting::getById($id);
$this->assertEquals('MyMeeting', $meeting->name);
$this->assertEquals($startStamp, $meeting->startDateTime);
$this->assertEquals($endStamp, $meeting->endDateTime);
$this->assertEquals('my test description', $meeting->description);
$this->assertEquals($user, $meeting->owner);
$this->assertEquals(4, $meeting->activityItems->count());
$this->assertEquals($accounts[0], $meeting->activityItems->offsetGet(0));
}
开发者ID:youprofit,项目名称:Zurmo,代码行数:35,代码来源:MeetingTest.php
示例11: 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
示例12: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
Yii::app()->user->userModel = User::getByUsername('super');
ReadPermissionsOptimizationUtil::rebuild();
SecurityTestHelper::createUsers();
$billy = User::getByUsername('billy');
EmailMessageTestHelper::createEmailAccount($billy);
$billy->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
$billy->setRight('ContactsModule', ContactsModule::RIGHT_CREATE_CONTACTS);
$billy->setRight('ContactsModule', ContactsModule::RIGHT_DELETE_CONTACTS);
assert($billy->save());
// Not Coding Standard
$contact = ContactTestHelper::createContactByNameForOwner('sally', Yii::app()->user->userModel);
$contact->primaryEmail = new Email();
$contact->primaryEmail->emailAddress = '[email protected]';
$contact->secondaryEmail->emailAddress = '[email protected]';
$contact->addPermissions($billy, Permission::READ);
$contact->addPermissions($billy, Permission::WRITE);
$contact->save();
$molly = ContactTestHelper::createContactByNameForOwner('molly', User::getByUsername('bobby'));
$molly->primaryEmail = new Email();
$molly->primaryEmail->emailAddress = '[email protected]';
$molly->secondaryEmail->emailAddress = '[email protected]';
$contact->save();
ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($contact, $billy);
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:28,代码来源:EmailMessageUtilTest.php
示例13: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$user = UserTestHelper::createBasicUser('steve');
$user->primaryEmail->emailAddress = '[email protected]';
$user->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
assert($user->save());
// Not Coding Standard
$contact1 = ContactTestHelper::createContactByNameForOwner('peter', $user);
$contact1->primaryEmail->emailAddress = '[email protected]';
$contact1->secondaryEmail->emailAddress = '[email protected]';
assert($contact1->save());
// Not Coding Standard
$contactsOrLeads = ContactSearch::getContactsByAnyEmailAddress('[email protected]', null, null);
$contact2 = ContactTestHelper::createContactByNameForOwner('jim', $user);
$contact2->primaryEmail->emailAddress = '[email protected]';
assert($contact2->save());
// Not Coding Standard
$nonExistingUserEmail = '[email protected]';
self::$user = $user;
self::$contact1 = $contact1;
self::$contact2 = $contact2;
self::$nonExistingUserEmail = $nonExistingUserEmail;
Yii::app()->imap->imapUsername = '[email protected]';
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:26,代码来源:EmailArchivingJobDocumentationTest.php
示例14: testRenderCorrectStateTranslationAfterCallingContactStateLabel
public function testRenderCorrectStateTranslationAfterCallingContactStateLabel()
{
$super = User::getByUsername('super');
$contact = ContactTestHelper::createContactByNameForOwner('test', $super);
ZurmoHtml::activeLabel($contact, 'state');
$element = new AddressElement($contact, 'primaryAddress', new ZurmoActiveForm());
$this->assertContains('<label for="Contact_primaryAddress_state">State</label>', $element->render());
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:8,代码来源:AddressElementTest.php
示例15: testResolveModelUrl
/**
* @depends testIsSpecialMergeTag
*/
public function testResolveModelUrl()
{
$contact = ContactTestHelper::createContactByNameForOwner('contact 01', Yii::app()->user->userModel);
$resolvedModelUrl = SpecialMergeTagsAdapter::resolve('modelUrl', $contact);
$this->assertNotNull($resolvedModelUrl);
$expectedSuffix = '/contacts/default/details?id=' . $contact->id;
$this->assertContains($expectedSuffix, $resolvedModelUrl);
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:11,代码来源:SpecialMergeTagsAdapterTest.php
示例16: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$emailBox = EmailBoxUtil::getDefaultEmailBoxByUser(User::getByUsername('super'));
ContactTestHelper::createContactByNameForOwner('contact01', Yii::app()->user->userModel);
ContactTestHelper::createContactByNameForOwner('contact02', Yii::app()->user->userModel);
ContactTestHelper::createContactByNameForOwner('contact03', Yii::app()->user->userModel);
}
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:9,代码来源:MarketingEmailsInThisListChartDataProviderTest.php
示例17: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
$super = Yii::app()->user->userModel;
//Setup test data owned by the super user.
$account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
AccountTestHelper::createAccountByNameForOwner('superAccount2', $super);
ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:9,代码来源:NotesRegularUserWalkthroughTest.php
示例18: testCreateEmailMessage
public function testCreateEmailMessage()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$authenticationData = $this->login();
$headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
// Test with at least one existing recipient
$data['subject'] = 'Test 1 Subject';
$data['textContent'] = 'Test 1 Text Content';
$data['htmlContent'] = 'Test 1 Html Content';
$data['sentFrom']['email'] = '[email protected]';
$data['recipients'] = array('to' => array(array('name' => 'TO1', 'email' => '[email protected]'), array('name' => 'TO2', 'email' => '[email protected]')), 'cc' => array(array('name' => 'CC1', 'email' => '[email protected]'), array('name' => 'CC2', 'email' => '[email protected]')));
$contact1 = ContactTestHelper::createContactByNameForOwner('TestContact1', $super);
$contact1->primaryEmail->emailAddress = '[email protected]';
$contact1->save();
$response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertArrayHasKey('id', $response['data']);
$emailMessageId = $response['data']['id'];
$emailMessage = EmailMessage::getById($emailMessageId);
$this->assertEquals('Test 1 Subject', $emailMessage->subject);
$this->assertEquals('Test 1 Text Content', $emailMessage->content->textContent);
$this->assertEquals('Test 1 Html Content', $emailMessage->content->htmlContent);
$this->assertEquals('[email protected]', $emailMessage->sender->fromAddress);
$this->assertEquals(EmailFolder::TYPE_ARCHIVED, $emailMessage->folder->type);
$this->assertEquals(4, count($emailMessage->recipients));
$this->assertEquals($data['recipients']['to'][0]['email'], $emailMessage->recipients[0]->toAddress);
$this->assertEquals($data['recipients']['to'][0]['name'], $emailMessage->recipients[0]->toName);
$this->assertEquals(EmailMessageRecipient::TYPE_TO, $emailMessage->recipients[0]->type);
$this->assertEquals($data['recipients']['to'][1]['email'], $emailMessage->recipients[1]->toAddress);
$this->assertEquals($data['recipients']['to'][1]['name'], $emailMessage->recipients[1]->toName);
$this->assertEquals(EmailMessageRecipient::TYPE_TO, $emailMessage->recipients[1]->type);
$this->assertEquals($data['recipients']['cc'][0]['email'], $emailMessage->recipients[2]->toAddress);
$this->assertEquals($data['recipients']['cc'][0]['name'], $emailMessage->recipients[2]->toName);
$this->assertEquals(EmailMessageRecipient::TYPE_CC, $emailMessage->recipients[2]->type);
$this->assertEquals($data['recipients']['cc'][1]['email'], $emailMessage->recipients[3]->toAddress);
$this->assertEquals($data['recipients']['cc'][1]['name'], $emailMessage->recipients[3]->toName);
$this->assertEquals(EmailMessageRecipient::TYPE_CC, $emailMessage->recipients[3]->type);
// Test without existing recipient
$data['subject'] = 'Test 2 Subject';
$data['textContent'] = 'Test 2 Text Content';
$data['htmlContent'] = 'Test 2 Html Content';
$data['sentFrom']['email'] = '[email protected]';
$data['recipients'] = array('to' => array(array('name' => 'TO11', 'email' => '[email protected]'), array('name' => 'TO21', 'email' => '[email protected]')));
$response = $this->createApiCallWithRelativeUrl('create/', 'POST', $headers, array('data' => $data));
$response = json_decode($response, true);
$this->assertArrayHasKey('id', $response['data']);
$emailMessageId = $response['data']['id'];
$emailMessage = EmailMessage::getById($emailMessageId);
$this->assertEquals('Test 2 Subject', $emailMessage->subject);
$this->assertEquals('Test 2 Text Content', $emailMessage->content->textContent);
$this->assertEquals('Test 2 Html Content', $emailMessage->content->htmlContent);
$this->assertEquals('[email protected]', $emailMessage->sender->fromAddress);
$this->assertEquals(EmailFolder::TYPE_ARCHIVED_UNMATCHED, $emailMessage->folder->type);
$this->assertEquals(2, count($emailMessage->recipients));
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:56,代码来源:ApiRestEmailMessageTest.php
示例19: 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->builtType = EmailTemplate::BUILT_TYPE_PASTED_HTML;
$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 = '[email protected]';
$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, WorkflowMessageInQueue::getCount());
$job = new WorkflowMessageInQueueJob();
$this->assertTrue($job->run());
$this->assertEquals(0, WorkflowMessageInQueue::getCount());
RedBeanModelsCache::forgetAll(true);
//simulates page change, required to confirm Item does not get trashed
$this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
}
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:62,代码来源:WorkflowMessageInQueueJobTest.php
示例20: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
SecurityTestHelper::createSuperAdmin();
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
//Setup test data owned by the super user.
$account = AccountTestHelper::createAccountByNameForOwner('superAccount', $super);
//Setup test data owned by the super user.
ContactTestHelper::createContactWithAccountByNameForOwner('superContact', $super, $account);
}
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:11,代码来源:ContactsSuperUserKanbanBoardWalkthroughTest.php
注:本文中的ContactTestHelper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论