本文整理汇总了PHP中EmailMessage::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailMessage::deleteAll方法的具体用法?PHP EmailMessage::deleteAll怎么用?PHP EmailMessage::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailMessage
的用法示例。
在下文中一共展示了EmailMessage::deleteAll方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
Yii::app()->user->userModel = User::getByUsername('super');
EmailMessage::deleteAll();
Notification::deleteAll();
}
示例2: testSendSystemEmail
public function testSendSystemEmail()
{
if (!EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) {
$this->markTestSkipped(Zurmo::t('EmailMessagesModule', 'Test email settings are not configured in perInstanceTest.php file.'));
}
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
Yii::app()->imap->connect();
EmailMessage::deleteAll();
// Expunge all emails from dropbox
Yii::app()->imap->deleteMessages(true);
$this->assertEquals(0, EmailMessage::getCount());
$imapStats = Yii::app()->imap->getMessageBoxStatsDetailed();
$this->assertEquals(0, $imapStats->Nmsgs);
$subject = "System Message";
$textMessage = "System message content.";
$htmlMessage = "<strong>System</strong> message content.";
EmailMessageHelper::sendSystemEmail($subject, array(Yii::app()->imap->imapUsername), $textMessage, $htmlMessage);
sleep(30);
Yii::app()->imap->connect();
$imapStats = Yii::app()->imap->getMessageBoxStatsDetailed();
$this->assertEquals(1, $imapStats->Nmsgs);
$this->assertEquals(1, EmailMessage::getCount());
$emailMessages = EmailMessage::getAll();
$emailMessage = $emailMessages[0];
$this->assertEquals('System Message', $emailMessage->subject);
$this->assertEquals('System message content.', trim($emailMessage->content->textContent));
$this->assertEquals('<strong>System</strong> message content.', trim($emailMessage->content->htmlContent));
$this->assertEquals(1, count($emailMessage->recipients));
foreach ($emailMessage->recipients as $recipient) {
$this->assertEquals($recipient->toAddress, Yii::app()->imap->imapUsername);
$this->assertEquals(EmailMessageRecipient::TYPE_TO, $recipient->type);
}
}
示例3: setUp
public function setUp()
{
parent::setUp();
$this->user = User::getByUsername('super');
Yii::app()->user->userModel = $this->user;
EmailAccount::deleteAll();
EmailMessage::deleteAll();
EmailMessageContent::deleteAll();
EmailMessageSender::deleteAll();
EmailMessageRecipient::deleteAll();
EmailMessageSendError::deleteAll();
FileModel::deleteAll();
}
示例4: setUp
public function setUp()
{
parent::setUp();
$this->user = User::getByUsername('super');
Yii::app()->user->userModel = $this->user;
EmailAccount::deleteAll();
EmailMessage::deleteAll();
EmailMessageContent::deleteAll();
EmailMessageSender::deleteAll();
EmailMessageRecipient::deleteAll();
EmailMessageSendError::deleteAll();
FileModel::deleteAll();
if (!EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) {
$this->markTestSkipped('Please fix the test email settings');
}
}
示例5: 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
//.........这里部分代码省略.........
示例6: testSendQueuedSkipsPausedCampaignMessages
/**
* @depends testSendQueued
*/
public function testSendQueuedSkipsPausedCampaignMessages()
{
EmailMessage::deleteAll();
$job = new CampaignQueueMessagesInOutboxJob();
$email = new Email();
$email->emailAddress = 'demo@zurmo.com';
$contact = ContactTestHelper::createContactByNameForOwner('contact', $this->user);
$contact->primaryEmail = $email;
$this->assertTrue($contact->save());
$marketingList = MarketingListTestHelper::createMarketingListByName('marketingList');
MarketingListMemberTestHelper::createMarketingListMember(0, $marketingList, $contact);
$campaign = CampaignTestHelper::createCampaign('campaign', 'subject', 'text Content', 'Html Content', null, null, null, Campaign::STATUS_PROCESSING, null, 0, $marketingList);
$processed = 0;
CampaignItemTestHelper::createCampaignItem($processed, $campaign, $contact);
$this->assertTrue($job->run());
$campaignItems = CampaignItem::getAll();
$this->assertCount(1, $campaignItems);
$campaignItemsProcessed = CampaignItem::getByProcessedAndCampaignId(1, $campaign->id);
$this->assertCount(1, $campaignItemsProcessed);
$campaign->status = Campaign::STATUS_PAUSED;
$this->assertTrue($campaign->save());
$this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
Yii::app()->emailHelper->sendQueued();
$this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
}
示例7: testSubmittingDuplicateNotifications
public function testSubmittingDuplicateNotifications()
{
$user = $this->user;
Notification::deleteAll();
EmailMessage::deleteAll();
$message = new NotificationMessage();
$message->textContent = 'text content';
$message->htmlContent = 'html content';
$rules = new SimpleNotificationRules();
$rules->setCritical(true);
$rules->setAllowDuplicates(false);
$rules->addUser($user);
NotificationsUtil::submit($message, $rules);
$this->assertEquals(1, Yii::app()->emailHelper->getSentCount());
$this->assertCount(1, Notification::getAll());
NotificationsUtil::submit($message, $rules);
$this->assertEquals(1, Yii::app()->emailHelper->getSentCount());
$this->assertCount(1, Notification::getAll());
$rules->setAllowDuplicates(true);
NotificationsUtil::submit($message, $rules);
$this->assertEquals(2, Yii::app()->emailHelper->getSentCount());
$this->assertCount(2, Notification::getAll());
}
示例8: testTaskStatusBecomesRejectedNotificationWhenOwnerIsNotCurrentUser
public function testTaskStatusBecomesRejectedNotificationWhenOwnerIsNotCurrentUser()
{
$task = new Task();
$task->name = 'RejectOwner Task';
$task->requestedByUser = self::$sally;
$task->owner = self::$katie;
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertTrue($task->save());
$this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
EmailMessage::deleteAll();
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
//Now change status
$task->status = Task::STATUS_REJECTED;
$this->assertTrue($task->save());
//One email should be queued up
$this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
$emailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX);
$this->assertCount(1, $emailMessages);
$this->assertEquals(1, $emailMessages[0]->recipients->count());
$this->assertEquals('katie@zurmo.com', $emailMessages[0]->recipients[0]->toAddress);
}
示例9: 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));
}
示例10: testCase6B
/**
* Test Case: email from User to Contact and CC to another Contact and BCC archive.
* Expected Behavior: Email is archived to both contact records.
*/
public function testCase6B()
{
EmailMessage::deleteAll();
$imapMessage = new ImapMessage();
$imapMessage->fromName = 'steve';
$imapMessage->fromEmail = self::$user->primaryEmail->emailAddress;
$imapMessage->senderEmail = self::$user->primaryEmail->emailAddress;
$imapMessage->to = array(array('name' => self::$contact1->firstName, 'email' => self::$contact1->primaryEmail->emailAddress));
$imapMessage->cc = array(array('name' => self::$contact2->firstName, 'email' => self::$contact2->primaryEmail->emailAddress));
$imapMessage->subject = "Test Email 6b";
$imapMessage->htmlBody = "<strong>Email</strong> from Steve 6b";
$imapMessage->textBody = "Email from Steve 6b";
$emailArchivingJob = new EmailArchivingJob();
$result = $emailArchivingJob->saveEmailMessage($imapMessage);
$this->assertTrue($result);
$emailMessages = EmailMessage::getAll();
$this->assertEquals(1, count($emailMessages));
$emailMessage = $emailMessages[0];
$this->assertEquals($imapMessage->subject, $emailMessage->subject);
$this->assertEquals($imapMessage->textBody, trim($emailMessage->content->textContent));
$this->assertEquals($imapMessage->htmlBody, trim($emailMessage->content->htmlContent));
$this->assertEquals(self::$user->primaryEmail->emailAddress, $emailMessage->sender->fromAddress);
$this->assertEquals(2, count($emailMessage->recipients));
$this->assertEquals(self::$contact1->primaryEmail->emailAddress, $emailMessage->recipients[0]->toAddress);
$this->assertEquals(EmailMessageRecipient::TYPE_TO, $emailMessage->recipients[0]->type);
$this->assertEquals(self::$contact2->primaryEmail->emailAddress, $emailMessage->recipients[1]->toAddress);
$this->assertEquals(EmailMessageRecipient::TYPE_CC, $emailMessage->recipients[1]->type);
$this->assertEquals(EmailFolder::TYPE_ARCHIVED, $emailMessage->folder->type);
}
示例11: testTaskNotifications
public function testTaskNotifications()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$userOwner = UserTestHelper::createBasicUserWithEmailAddress('TaskUserOwner');
$userRequester = UserTestHelper::createBasicUserWithEmailAddress('TaskUserRequester');
Notification::deleteAll();
EmailMessage::deleteAll();
$dueStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 10000);
$completedStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time() + 9000);
$task = new Task();
$task->name = 'Task for Notifications Test';
$task->owner = $userOwner;
$task->requestedByUser = $userRequester;
$task->dueDateTime = $dueStamp;
$task->completedDateTime = $completedStamp;
$task->description = 'my test description';
$task->status = Task::STATUS_NEW;
$this->assertTrue($task->save());
//New task notification owned by other
$notifications = Notification::getAll();
$emailMessages = EmailMessage::getAll();
$this->assertCount(1, $notifications);
$this->assertCount(1, $emailMessages);
$this->assertContains("The task, 'Task for Notifications Test', is now owned by you.", $notifications[0]->notificationMessage->textContent);
$this->assertContains("The task, 'Task for Notifications Test', is now owned by you.", $emailMessages[0]->content->textContent);
//Deliver task notification
$task->status = TASK::STATUS_AWAITING_ACCEPTANCE;
$task->save();
$notifications = Notification::getAll();
$emailMessages = EmailMessage::getAll();
$this->assertCount(2, $notifications);
$this->assertCount(2, $emailMessages);
$this->assertContains("The task you requested, 'Task for Notifications Test', has been finished. You can now choose to accept or reject the task.", $notifications[1]->notificationMessage->textContent);
$this->assertContains("The task you requested, 'Task for Notifications Test', has been finished. You can now choose to accept or reject the task.", $emailMessages[1]->content->textContent);
//Reject task notification
$task->status = TASK::STATUS_REJECTED;
$task->save();
$notifications = Notification::getAll();
$emailMessages = EmailMessage::getAll();
$this->assertCount(3, $notifications);
$this->assertCount(3, $emailMessages);
$this->assertContains("The task, 'Task for Notifications Test', has been rejected by Clark Kent.", $notifications[2]->notificationMessage->textContent);
$this->assertContains("The task, 'Task for Notifications Test', has been rejected by Clark Kent.", $emailMessages[2]->content->textContent);
//Accept task notification
$task->status = TASK::STATUS_COMPLETED;
$task->save();
$notifications = Notification::getAll();
$emailMessages = EmailMessage::getAll();
$this->assertCount(4, $notifications);
$this->assertCount(4, $emailMessages);
$this->assertContains("The task, 'Task for Notifications Test', was accepted by Clark Kent.", $notifications[3]->notificationMessage->textContent);
$this->assertContains("The task, 'Task for Notifications Test', was accepted by Clark Kent.", $emailMessages[3]->content->textContent);
}
示例12: testProjectNotifications
public function testProjectNotifications()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$super->primaryEmail->emailAddress = 'super@zurmo.com';
$super->save();
Yii::app()->user->userModel = $super;
$user = UserTestHelper::createBasicUser('ProjectUser');
Notification::deleteAll();
EmailMessage::deleteAll();
$project = new Project();
$project->name = 'Project For Notifications Test';
$project->owner = $super;
$project->description = 'Description';
$this->assertTrue($project->save());
//New project notification
$notifications = Notification::getAll();
$emailMessages = EmailMessage::getAll();
$this->assertCount(1, $notifications);
$this->assertCount(1, $emailMessages);
$this->assertContains("The project, 'Project For Notifications Test', is now owned by you.", $notifications[0]->notificationMessage->textContent);
$this->assertContains("The project, 'Project For Notifications Test', is now owned by you.", $emailMessages[0]->content->textContent);
//Project archived notification
$project->status = Project::STATUS_ARCHIVED;
$this->assertTrue($project->save());
$notifications = Notification::getAll();
$emailMessages = EmailMessage::getAll();
$this->assertCount(2, $notifications);
$this->assertCount(2, $emailMessages);
$this->assertContains("The project, 'Project For Notifications Test', is now archived.", $notifications[1]->notificationMessage->textContent);
$this->assertContains("The project, 'Project For Notifications Test', is now archived.", $emailMessages[1]->content->textContent);
}
示例13: testSendNotificationInNewComment
/**
* @depends testAjaxChangeStatus
*/
public function testSendNotificationInNewComment()
{
$this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$missions = Mission::getAll();
$this->assertEquals(1, count($missions));
$mission = $missions[0];
$this->assertEquals(0, $mission->comments->count());
EmailMessage::deleteAll();
Notification::deleteAll();
$messageCount = 0;
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
//Save new comment.
$this->setGetArray(array('relatedModelId' => $mission->id, 'relatedModelClassName' => 'Mission', 'relatedModelRelationName' => 'comments', 'redirectUrl' => 'someRedirect'));
$this->setPostArray(array('Comment' => array('description' => 'a ValidComment Name')));
$this->runControllerWithRedirectExceptionAndGetContent('comments/default/inlineCreateSave');
$this->assertEquals(1, $mission->comments->count());
$this->assertEquals($messageCount + 1, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
$emailMessages = EmailMessage::getAll();
$emailMessage = $emailMessages[$messageCount];
$this->assertEquals(1, count($emailMessage->recipients));
$this->assertContains('mission', $emailMessage->subject);
$this->assertContains(strval($mission), $emailMessage->subject);
$this->assertContains(strval($mission->comments[0]), $emailMessage->content->htmlContent);
$this->assertContains(strval($mission->comments[0]), $emailMessage->content->textContent);
$notifications = Notification::getAll();
$notification = $notifications[$messageCount];
$this->assertCount(1, $notifications);
$this->assertEquals('Mission new comment', strval($notification));
$this->assertContains(strval($mission->comments[0]), $notification->notificationMessage->htmlContent);
$this->assertContains(strval($mission->comments[0]), $notification->notificationMessage->textContent);
}