本文整理汇总了PHP中Notification::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::deleteAll方法的具体用法?PHP Notification::deleteAll怎么用?PHP Notification::deleteAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::deleteAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
Yii::app()->user->userModel = User::getByUsername('super');
EmailMessage::deleteAll();
Notification::deleteAll();
}
示例2: 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());
}
示例3: testTaskAddCommentWithExtraSubscribers
public function testTaskAddCommentWithExtraSubscribers()
{
$task = new Task();
$task->name = 'Her Task';
$task->owner = self::$sally;
$task->requestedByUser = self::$katie;
$notificationSubscriber = new NotificationSubscriber();
$notificationSubscriber->person = self::$steve;
$notificationSubscriber->hasReadLatest = false;
$task->notificationSubscribers->add($notificationSubscriber);
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Notification::getCount());
$this->assertTrue($task->save());
$this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(1, Notification::getCount());
EmailMessage::deleteAll();
Notification::deleteAll();
$taskId = $task->id;
$task->forget();
$task = Task::getById($taskId);
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Notification::getCount());
//Now add comment
$comment = new Comment();
$comment->description = 'some comment';
$task->comments->add($comment);
$this->assertTrue($task->save());
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Notification::getCount());
TasksNotificationUtil::submitTaskNotificationMessage($task, TasksNotificationUtil::TASK_NEW_COMMENT, self::$super, $comment);
$this->assertEquals(3, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(3, Notification::getCount());
$emailMessages = EmailMessage::getAllByFolderType(EmailFolder::TYPE_OUTBOX);
$this->assertCount(3, $emailMessages);
$this->assertTrue('katie@zurmo.com' == $emailMessages[0]->recipients[0]->toAddress || 'katie@zurmo.com' == $emailMessages[1]->recipients[0]->toAddress || 'katie@zurmo.com' == $emailMessages[2]->recipients[0]->toAddress);
$this->assertTrue('sally@zurmo.com' == $emailMessages[0]->recipients[0]->toAddress || 'sally@zurmo.com' == $emailMessages[1]->recipients[0]->toAddress || 'sally@zurmo.com' == $emailMessages[2]->recipients[0]->toAddress);
$this->assertTrue('steve@zurmo.com' == $emailMessages[0]->recipients[0]->toAddress || 'steve@zurmo.com' == $emailMessages[1]->recipients[0]->toAddress || 'steve@zurmo.com' == $emailMessages[2]->recipients[0]->toAddress);
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: testAsynchronousDownloadDefaultControllerActions
/**
* Walkthrough test for synchronous download
*/
public function testAsynchronousDownloadDefaultControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
Project::deleteAll();
$projects = array();
for ($i = 0; $i <= ExportModule::$asynchronousThreshold + 1; $i++) {
$projects[] = ProjectTestHelper::createProjectByNameForOwner('superProject' . $i, $super);
}
Notification::deleteAll();
NotificationMessage::deleteAll();
$this->setGetArray(array('Project_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
$this->runControllerWithRedirectExceptionAndGetUrl('projects/default/export');
// Start background job
$job = new ExportJob();
$this->assertTrue($job->run());
$exportItems = ExportItem::getAll();
$this->assertEquals(1, count($exportItems));
$fileModel = $exportItems[0]->exportFileModel;
$this->assertEquals(1, $exportItems[0]->isCompleted);
$this->assertEquals('csv', $exportItems[0]->exportFileType);
$this->assertEquals('projects', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals(1, Notification::getCount());
$this->assertEquals(1, NotificationMessage::getCount());
// Check export job, when many ids are selected.
// This will probably never happen, but we need test for this case too.
$notificationsBeforeCount = Notification::getCount();
$notificationMessagesBeforeCount = NotificationMessage::getCount();
// Now test case when multiple ids are selected
$exportItems = ExportItem::deleteAll();
$selectedIds = "";
foreach ($projects as $project) {
$selectedIds .= $project->id . ",";
// Not Coding Standard
}
$this->setGetArray(array('ProjectsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => ''), 'multiselect_ProjectsSearchForm_anyMixedAttributesScope' => 'All', 'Project_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$selectedIds}"));
$this->runControllerWithRedirectExceptionAndGetUrl('projects/default/export');
// Start background job
$job = new ExportJob();
$this->assertTrue($job->run());
$exportItems = ExportItem::getAll();
$this->assertEquals(1, count($exportItems));
$fileModel = $exportItems[0]->exportFileModel;
$this->assertEquals(1, $exportItems[0]->isCompleted);
$this->assertEquals('csv', $exportItems[0]->exportFileType);
$this->assertEquals('projects', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals(2, Notification::getCount());
$this->assertEquals(2, NotificationMessage::getCount());
}