本文整理汇总了PHP中EmailBox::save方法的典型用法代码示例。如果您正苦于以下问题:PHP EmailBox::save方法的具体用法?PHP EmailBox::save怎么用?PHP EmailBox::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EmailBox
的用法示例。
在下文中一共展示了EmailBox::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetAndGetFolder
/**
* @depends testGetByBoxAndTypeForNotificationsBox
*/
public function testSetAndGetFolder()
{
$billy = User::getByUsername('billy');
Yii::app()->user->userModel = $billy;
$folders = EmailFolder::getAll();
$this->assertEquals(8, count($folders));
$box = new EmailBox();
$box->name = 'Some new mailbox';
$saved = $box->save();
$this->assertTrue($saved);
$this->assertEquals(0, $box->folders->count());
$folder = new EmailFolder();
$folder->name = 'Billy\'s Inbox';
$folder->type = EmailFolder::TYPE_INBOX;
$saved = $folder->save();
//Missing 'box', so it should not save
$this->assertFalse($saved);
$folder->emailBox = $box;
$saved = $folder->save();
$this->assertTrue($saved);
$folderId = $folder->id;
$folder->forget();
unset($folder);
$folder = EmailFolder::getById($folderId);
$this->assertEquals($box->id, $folder->emailBox->id);
//Now check the box has the correct folder related to it
$boxId = $box->id;
$box->forget();
unset($box);
$box = EmailBox::getById($boxId);
$this->assertEquals(1, $box->folders->count());
$this->assertEquals('Billy\'s Inbox', $box->folders[0]->name);
$this->assertEquals(EmailFolder::TYPE_INBOX, $box->folders[0]->type);
$folders = EmailFolder::getAll();
$this->assertEquals(9, count($folders));
//Now delete billy's inbox
$folder->delete();
$folders = EmailFolder::getAll();
$this->assertEquals(8, count($folders));
$box->forget();
unset($box);
$box = EmailBox::getById($boxId);
$this->assertEquals(0, $box->folders->count());
}
示例2: 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;
}
示例3: testSetAndGetMailbox
/**
* @depends testNotificationsBoxResolvesCorrectly
*/
public function testSetAndGetMailbox()
{
$super = User::getByUsername('super');
Yii::app()->user->userModel = $super;
$boxes = EmailBox::getAll();
$this->assertEquals(1, count($boxes));
$box = new EmailBox();
$box->name = 'Some new mailbox';
$saved = $box->save();
$this->assertTrue($saved);
$this->assertEquals(0, $box->folders->count());
$this->assertTrue($box->isDeletable());
//Now try deleting the box
$boxes = EmailBox::getAll();
$this->assertEquals(2, count($boxes));
$box->delete();
$boxes = EmailBox::getAll();
$this->assertEquals(1, count($boxes));
}
示例4: 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;
}