本文整理汇总了PHP中EmailFolder::getDefaultDraftName方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailFolder::getDefaultDraftName方法的具体用法?PHP EmailFolder::getDefaultDraftName怎么用?PHP EmailFolder::getDefaultDraftName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailFolder
的用法示例。
在下文中一共展示了EmailFolder::getDefaultDraftName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createBoxAndDefaultFoldersByUserAndName
/**
* Given a box name and user, create an email box with the default folders.
* @param User $user
* @param string $name
*/
public static function createBoxAndDefaultFoldersByUserAndName(User $user, $name)
{
assert('$user->id > 0');
assert('is_string($name)');
$box = new EmailBox();
$box->name = $name;
$box->user = $user;
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultDraftName();
$folder->type = EmailFolder::TYPE_DRAFT;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultInboxName();
$folder->type = EmailFolder::TYPE_INBOX;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultSentName();
$folder->type = EmailFolder::TYPE_SENT;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxName();
$folder->type = EmailFolder::TYPE_OUTBOX;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxErrorName();
$folder->type = EmailFolder::TYPE_OUTBOX_ERROR;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxFailureName();
$folder->type = EmailFolder::TYPE_OUTBOX_FAILURE;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultArchivedName();
$folder->type = EmailFolder::TYPE_ARCHIVED;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultArchivedUnmatchedName();
$folder->type = EmailFolder::TYPE_ARCHIVED_UNMATCHED;
$folder->emailBox = $box;
$box->folders->add($folder);
$saved = $box->save();
if (!$saved) {
throw new NotSupportedException();
}
return $box;
}
示例2: makeSystemMissingBox
protected static function makeSystemMissingBox($name)
{
$box = new EmailBox();
$box->name = $name;
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultDraftName();
$folder->type = EmailFolder::TYPE_DRAFT;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultSentName();
$folder->type = EmailFolder::TYPE_SENT;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxName();
$folder->type = EmailFolder::TYPE_OUTBOX;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxErrorName();
$folder->type = EmailFolder::TYPE_OUTBOX_ERROR;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultOutboxFailureName();
$folder->type = EmailFolder::TYPE_OUTBOX_FAILURE;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultInboxName();
$folder->type = EmailFolder::TYPE_INBOX;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultArchivedName();
$folder->type = EmailFolder::TYPE_ARCHIVED;
$folder->emailBox = $box;
$box->folders->add($folder);
$folder = new EmailFolder();
$folder->name = EmailFolder::getDefaultArchivedUnmatchedName();
$folder->type = EmailFolder::TYPE_ARCHIVED_UNMATCHED;
$folder->emailBox = $box;
$box->folders->add($folder);
$saved = $box->save();
assert('$saved');
return $box;
}
示例3: testUserDefaultBoxBoxResolvesCorrectly
/**
* @depends testTryDeletingTheNotificationsBox
*/
public function testUserDefaultBoxBoxResolvesCorrectly()
{
$jane = User::getByUsername('jane');
Yii::app()->user->userModel = $jane;
$boxes = EmailBox::getAll();
$this->assertEquals(1, count($boxes));
$box = EmailBoxUtil::getDefaultEmailBoxByUser($jane);
$this->assertEquals(EmailBox::USER_DEFAULT_NAME, $box->name);
$this->assertEquals(8, $box->folders->count());
$this->assertTrue($box->isDeletable());
$this->assertTrue($box->id > 0);
//After it saves, it should create a Sent folder and an Outbox folder
$boxes = EmailBox::getAll();
$this->assertEquals(2, count($boxes));
$jane->forget();
$jane = User::getByUsername('jane');
Yii::app()->user->userModel = $jane;
$this->assertEquals(1, $jane->emailBoxes->count());
$box = $jane->emailBoxes->offsetGet(0);
$this->assertEquals(8, $box->folders->count());
$folder1 = $box->folders->offsetGet(0);
$folder2 = $box->folders->offsetGet(1);
$folder3 = $box->folders->offsetGet(2);
$folder4 = $box->folders->offsetGet(3);
$folder5 = $box->folders->offsetGet(4);
$folder6 = $box->folders->offsetGet(5);
$folder7 = $box->folders->offsetGet(6);
$folder8 = $box->folders->offsetGet(7);
$this->assertTrue($folder1->name == EmailFolder::getDefaultInboxName() || $folder1->name == EmailFolder::getDefaultSentName() || $folder1->name == EmailFolder::getDefaultOutboxName() || $folder1->name == EmailFolder::getDefaultDraftName() || $folder1->name == EmailFolder::getDefaultOutboxErrorName() || $folder1->name == EmailFolder::getDefaultOutboxFailureName() || $folder1->name == EmailFolder::getDefaultArchivedName() || $folder1->name == EmailFolder::getDefaultArchivedUnmatchedName());
$this->assertTrue($folder2->name == EmailFolder::getDefaultInboxName() || $folder2->name == EmailFolder::getDefaultSentName() || $folder2->name == EmailFolder::getDefaultOutboxName() || $folder2->name == EmailFolder::getDefaultDraftName() || $folder2->name == EmailFolder::getDefaultOutboxErrorName() || $folder2->name == EmailFolder::getDefaultOutboxFailureName() || $folder2->name == EmailFolder::getDefaultArchivedName() || $folder2->name == EmailFolder::getDefaultArchivedUnmatchedName());
$this->assertTrue($folder3->name == EmailFolder::getDefaultInboxName() || $folder3->name == EmailFolder::getDefaultSentName() || $folder3->name == EmailFolder::getDefaultOutboxName() || $folder3->name == EmailFolder::getDefaultDraftName() || $folder3->name == EmailFolder::getDefaultOutboxErrorName() || $folder3->name == EmailFolder::getDefaultOutboxFailureName() || $folder3->name == EmailFolder::getDefaultArchivedName() || $folder3->name == EmailFolder::getDefaultArchivedUnmatchedName());
$this->assertTrue($folder4->name == EmailFolder::getDefaultInboxName() || $folder4->name == EmailFolder::getDefaultSentName() || $folder4->name == EmailFolder::getDefaultOutboxName() || $folder4->name == EmailFolder::getDefaultDraftName() || $folder4->name == EmailFolder::getDefaultOutboxErrorName() || $folder4->name == EmailFolder::getDefaultOutboxFailureName() || $folder4->name == EmailFolder::getDefaultArchivedName() || $folder4->name == EmailFolder::getDefaultArchivedUnmatchedName());
$this->assertTrue($folder5->name == EmailFolder::getDefaultInboxName() || $folder5->name == EmailFolder::getDefaultSentName() || $folder5->name == EmailFolder::getDefaultOutboxName() || $folder5->name == EmailFolder::getDefaultDraftName() || $folder5->name == EmailFolder::getDefaultOutboxErrorName() || $folder5->name == EmailFolder::getDefaultOutboxFailureName() || $folder5->name == EmailFolder::getDefaultArchivedName() || $folder5->name == EmailFolder::getDefaultArchivedUnmatchedName());
$this->assertTrue($folder6->name == EmailFolder::getDefaultInboxName() || $folder6->name == EmailFolder::getDefaultSentName() || $folder6->name == EmailFolder::getDefaultOutboxName() || $folder6->name == EmailFolder::getDefaultDraftName() || $folder6->name == EmailFolder::getDefaultOutboxErrorName() || $folder6->name == EmailFolder::getDefaultOutboxFailureName() || $folder6->name == EmailFolder::getDefaultArchivedName() || $folder6->name == EmailFolder::getDefaultArchivedUnmatchedName());
$this->assertTrue($folder7->name == EmailFolder::getDefaultInboxName() || $folder7->name == EmailFolder::getDefaultSentName() || $folder7->name == EmailFolder::getDefaultOutboxName() || $folder7->name == EmailFolder::getDefaultDraftName() || $folder7->name == EmailFolder::getDefaultOutboxErrorName() || $folder7->name == EmailFolder::getDefaultOutboxFailureName() || $folder7->name == EmailFolder::getDefaultArchivedName() || $folder7->name == EmailFolder::getDefaultArchivedUnmatchedName());
$this->assertTrue($folder8->name == EmailFolder::getDefaultInboxName() || $folder8->name == EmailFolder::getDefaultSentName() || $folder8->name == EmailFolder::getDefaultOutboxName() || $folder8->name == EmailFolder::getDefaultDraftName() || $folder8->name == EmailFolder::getDefaultOutboxErrorName() || $folder8->name == EmailFolder::getDefaultOutboxFailureName() || $folder8->name == EmailFolder::getDefaultArchivedName() || $folder8->name == EmailFolder::getDefaultArchivedUnmatchedName());
$this->assertNotEquals($folder1->name, $folder2->name);
$this->assertNotEquals($folder1->name, $folder3->name);
$this->assertNotEquals($folder1->name, $folder4->name);
$this->assertNotEquals($folder1->name, $folder5->name);
$this->assertNotEquals($folder1->name, $folder6->name);
$this->assertNotEquals($folder1->name, $folder7->name);
$this->assertNotEquals($folder1->name, $folder8->name);
$this->assertNotEquals($folder2->name, $folder3->name);
$this->assertNotEquals($folder2->name, $folder4->name);
$this->assertNotEquals($folder2->name, $folder5->name);
$this->assertNotEquals($folder2->name, $folder6->name);
$this->assertNotEquals($folder2->name, $folder7->name);
$this->assertNotEquals($folder2->name, $folder8->name);
$this->assertNotEquals($folder3->name, $folder4->name);
$this->assertNotEquals($folder3->name, $folder5->name);
$this->assertNotEquals($folder3->name, $folder6->name);
$this->assertNotEquals($folder3->name, $folder7->name);
$this->assertNotEquals($folder3->name, $folder8->name);
$this->assertNotEquals($folder4->name, $folder5->name);
$this->assertNotEquals($folder4->name, $folder6->name);
$this->assertNotEquals($folder4->name, $folder7->name);
$this->assertNotEquals($folder4->name, $folder8->name);
$this->assertNotEquals($folder5->name, $folder6->name);
$this->assertNotEquals($folder5->name, $folder7->name);
$this->assertNotEquals($folder5->name, $folder8->name);
$this->assertNotEquals($folder6->name, $folder7->name);
$this->assertNotEquals($folder6->name, $folder8->name);
$this->assertNotEquals($folder7->name, $folder8->name);
$boxes = EmailBox::getAll();
$this->assertEquals(2, count($boxes));
$this->assertEquals($boxes[1]->user->id, $jane->id);
$jane->forget();
$jane = User::getByUsername('jane');
Yii::app()->user->userModel = $jane;
$this->assertEquals(1, $jane->emailBoxes->count());
$this->assertEquals($jane->emailBoxes->offsetGet(0), $boxes[1]);
// Check if only one default email box is created for user
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$jimmy = UserTestHelper::createBasicUser('jimmy');
$saved = $jimmy->save();
$this->assertTrue($saved);
Yii::app()->user->userModel = $jimmy;
$jimmysId = $jimmy->id;
$this->assertTrue($jimmysId > 0);
$this->assertTrue($jimmy->emailBoxes->count() == 0);
EmailBoxUtil::getDefaultEmailBoxByUser($jimmy);
//still doesn't show from the user side, because it was added via the other side.
$this->assertTrue($jimmy->emailBoxes->count() == 0);
$jimmysId = $jimmy->id;
$jimmy->forget();
$jimmy = User::getById($jimmysId);
//now we forgot and re-retrieved so it should still show
$this->assertTrue($jimmy->emailBoxes->count() == 1);
EmailBoxUtil::getDefaultEmailBoxByUser($jimmy);
// This command shouldn't create new box because we have manually refreshed user
$boxes = EmailBox::getAll();
// Note that two new boxes are created for use jimmy instead one.
// Probably because $jimmy->emailBoxes->count() return 0
$this->assertEquals(3, count($boxes));
}
示例4: testCreateEmailMessageThatIsANotification
/**
* A notification email is different than a regular outbound email because it is owned by a super user
* that is different than the user logged in. So the sender does not have a 'person'
*/
public function testCreateEmailMessageThatIsANotification()
{
$billy = User::getByUsername('billy');
$this->assertEquals(0, EmailMessage::getCount());
$emailMessage = new EmailMessage();
$emailMessage->owner = BaseControlUserConfigUtil::getUserToRunAs();
$emailMessage->subject = 'My First Email';
//Attempt to save without setting required information
$saved = $emailMessage->save();
$this->assertFalse($saved);
$compareData = array('folder' => array('name' => array('Name cannot be blank.'), 'emailBox' => array('name' => array('Name cannot be blank.'))), 'sender' => array('fromAddress' => array('From Address cannot be blank.')));
$this->assertEquals($compareData, $emailMessage->getErrors());
//Set sender, and recipient, and content
$emailContent = new EmailMessageContent();
$emailContent->textContent = 'My First Message';
$emailContent->htmlContent = 'Some fake HTML content';
$emailMessage->content = $emailContent;
//Sending from the system, does not have a 'person'.
$sender = new EmailMessageSender();
$sender->fromAddress = 'system@somewhere.com';
$sender->fromName = 'Zurmo System';
$emailMessage->sender = $sender;
//Recipient is billy.
$recipient = new EmailMessageRecipient();
$recipient->toAddress = 'billy@fakeemail.com';
$recipient->toName = 'Billy James';
$recipient->type = EmailMessageRecipient::TYPE_TO;
$recipient->personsOrAccounts->add($billy);
$emailMessage->recipients->add($recipient);
//At this point the message is in no folder
$this->assertTrue($emailMessage->folder->id < 0);
$box = EmailBox::resolveAndGetByName(EmailBox::NOTIFICATIONS_NAME);
$emailMessage->folder = EmailFolder::getByBoxAndType($box, EmailFolder::TYPE_DRAFT);
//Save, at this point the email should be in the draft folder
$saved = $emailMessage->save();
$this->assertTrue($saved);
$this->assertTrue($emailMessage->folder->id > 0);
//At this point the message should be in the draft folder by default.
$this->assertEquals(EmailFolder::getDefaultDraftName(), $emailMessage->folder->name);
$this->assertEquals(EmailFolder::TYPE_DRAFT, $emailMessage->folder->type);
}