本文整理汇总了PHP中Notification::getCount方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::getCount方法的具体用法?PHP Notification::getCount怎么用?PHP Notification::getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notification
的用法示例。
在下文中一共展示了Notification::getCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRun
public function testRun()
{
//Create workflow
$workflow = new Workflow();
$workflow->setDescription('aDescription');
$workflow->setIsActive(true);
$workflow->setOrder(5);
$workflow->setModuleClassName('WorkflowsTest2Module');
$workflow->setName('myFirstWorkflow');
$workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
$workflow->setType(Workflow::TYPE_ON_SAVE);
$workflow->setTriggersStructure('1');
//Add action that is missing required owner
$action = new ActionForWorkflowForm('WorkflowModelTestItem2', Workflow::TYPE_ON_SAVE);
$action->type = ActionForWorkflowForm::TYPE_CREATE;
$action->relation = 'hasMany2';
$attributes = array('string' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason'), 'lastName' => array('shouldSetValue' => '1', 'type' => WorkflowActionAttributeForm::TYPE_STATIC, 'value' => 'jason'));
$action->setAttributes(array(ActionForWorkflowForm::ACTION_ATTRIBUTES => $attributes));
$workflow->addAction($action);
//Create the saved Workflow
$savedWorkflow = new SavedWorkflow();
SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
$saved = $savedWorkflow->save();
$this->assertTrue($saved);
$this->assertEquals(0, Notification::getCount());
$job = new WorkflowValidityCheckJob();
$this->assertTrue($job->run());
$notifications = Notification::getAll();
$this->assertEquals(1, count($notifications));
}
示例2: getUnreadCountForCurrentUser
public function getUnreadCountForCurrentUser()
{
$searchAttributeData = $this->getMetadataFilteredByFilteredBy(MashableInboxForm::FILTERED_BY_UNREAD);
$joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Notification');
$where = RedBeanModelDataProvider::makeWhere('Notification', $searchAttributeData, $joinTablesAdapter);
return Notification::getCount($joinTablesAdapter, $where, null, true);
}
示例3: testProcessWorkflowAfterSave
public function testProcessWorkflowAfterSave()
{
$model = new WorkflowModelTestItem();
$event = new CEvent($model);
$observer = new WorkflowsObserver();
$observer->setDepth(25);
$this->assertEquals(0, Notification::getCount());
$observer->processWorkflowAfterSave($event);
$this->assertEquals(1, Notification::getCount());
}
示例4: testLogAndNotifyOnDuplicateGameModel
/**
* The best we can cover for is making sure the notification is created and it is not marked as critical.
*/
public function testLogAndNotifyOnDuplicateGameModel()
{
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
$this->assertEquals(0, Notification::getCount());
GamificationUtil::logAndNotifyOnDuplicateGameModel('some content');
//It should not send an email because it is non-allowed to send email notification
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
$this->assertEquals(1, Notification::getCount());
}
示例5: testExportAction
/**
* @depends testCreateActionForRowsAndColumns
*/
public function testExportAction()
{
$notificationsBeforeCount = Notification::getCount();
$notificationMessagesBeforeCount = NotificationMessage::getCount();
$savedReports = SavedReport::getAll();
$this->assertEquals(2, count($savedReports));
$this->setGetArray(array('id' => $savedReports[0]->id));
//Test where there is no data to export
$this->runControllerWithRedirectExceptionAndGetContent('reports/default/export');
$this->assertContains('There is no data to export.', Yii::app()->user->getFlash('notification'));
$reportModelTestItem = new ReportModelTestItem();
$reportModelTestItem->string = 'string1';
$reportModelTestItem->lastName = 'xLast1';
$this->assertTrue($reportModelTestItem->save());
$reportModelTestItem = new ReportModelTestItem();
$reportModelTestItem->string = 'string2';
$reportModelTestItem->lastName = 'xLast2';
$this->assertTrue($reportModelTestItem->save());
$content = $this->runControllerWithExitExceptionAndGetContent('reports/default/export');
$this->assertEquals('Testing download.', $content);
ExportModule::$asynchronousThreshold = 1;
$this->runControllerWithRedirectExceptionAndGetUrl('reports/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('reports', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
$this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
}
示例6: testRunWithMissingTriggerMultiselectPicklistValue
public function testRunWithMissingTriggerMultiselectPicklistValue()
{
$this->clearNotificationsWorkflowsAndEmailMessages();
$this->createStageValues();
//Create workflow
$workflow = new Workflow();
$workflow->setDescription('bDescription');
$workflow->setIsActive(true);
$workflow->setOrder(5);
$workflow->setModuleClassName('OpportunitiesModule');
$workflow->setName('mySecondWorkflow');
$workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
$workflow->setType(Workflow::TYPE_ON_SAVE);
$workflow->setTriggersStructure('1');
$trigger = new TriggerForWorkflowForm('OpportunitiesModule', 'Opportunity', Workflow::TYPE_ON_SAVE);
$trigger->attributeIndexOrDerivedType = 'stage';
$trigger->value = 'Closed Won,Negotiating';
$trigger->operator = OperatorRules::TYPE_ONE_OF;
$trigger->relationFilter = TriggerForWorkflowForm::RELATION_FILTER_ANY;
$workflow->addTrigger($trigger);
//Create the saved Workflow
$savedWorkflow = new SavedWorkflow();
SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
$saved = $savedWorkflow->save();
$this->assertTrue($saved);
$this->assertEquals(0, Notification::getCount());
$this->assertEquals(0, EmailMessage::getCount());
$job = new WorkflowValidityCheckJob();
$this->assertTrue($job->run());
$this->assertEquals(0, Notification::getCount());
$this->assertEquals(0, EmailMessage::getCount());
$this->clearNotificationsWorkflowsAndEmailMessages();
$workflow = new Workflow();
$workflow->setDescription('cDescription');
$workflow->setIsActive(true);
$workflow->setOrder(5);
$workflow->setModuleClassName('OpportunitiesModule');
$workflow->setName('mySecondWorkflow');
$workflow->setTriggerOn(Workflow::TRIGGER_ON_NEW_AND_EXISTING);
$workflow->setType(Workflow::TYPE_ON_SAVE);
$workflow->setTriggersStructure('1');
$trigger = new TriggerForWorkflowForm('OpportunitiesModule', 'Opportunity', Workflow::TYPE_ON_SAVE);
$trigger->attributeIndexOrDerivedType = 'stage';
$trigger->value = 'Closed Won,Unexisting state';
$trigger->operator = OperatorRules::TYPE_BECOMES;
$trigger->relationFilter = TriggerForWorkflowForm::RELATION_FILTER_ANY;
$workflow->addTrigger($trigger);
//Create the saved Workflow
$savedWorkflow = new SavedWorkflow();
SavedWorkflowToWorkflowAdapter::resolveWorkflowToSavedWorkflow($workflow, $savedWorkflow);
$saved = $savedWorkflow->save();
$this->assertTrue($saved);
$this->assertEquals(0, Notification::getCount());
$this->assertEquals(0, EmailMessage::getCount());
$job = new WorkflowValidityCheckJob();
$this->assertTrue($job->run());
$this->assertEquals(1, Notification::getCount());
$this->assertEquals(1, EmailMessage::getCount());
}
示例7: testSubmitWithInboxNotificationSettingDisabledAndEmailNotificationSettingDisabled
public function testSubmitWithInboxNotificationSettingDisabledAndEmailNotificationSettingDisabled()
{
$initialNotificationCount = Notification::getCount();
$initialEmailMessageCount = EmailMessage::getCount();
$rules = new SimpleNotificationRules();
$rules->setAllowDuplicates(true);
$rules->addUser($this->user);
$inboxAndEmailNotificationSettings = UserTestHelper::getDefaultNotificationSettingsValuesForTestUser();
$inboxAndEmailNotificationSettings['enableSimpleNotification']['email'] = false;
$inboxAndEmailNotificationSettings['enableSimpleNotification']['inbox'] = false;
UserNotificationUtil::setValue($this->user, $inboxAndEmailNotificationSettings, 'inboxAndEmailNotificationSettings', false);
$this->assertFalse(UserNotificationUtil::isEnabledByUserAndNotificationNameAndType($this->user, 'enableSimpleNotification', 'email'));
$this->assertFalse(UserNotificationUtil::isEnabledByUserAndNotificationNameAndType($this->user, 'enableSimpleNotification', 'inbox'));
$message = new NotificationMessage();
$message->textContent = 'text content for' . __FUNCTION__;
$message->htmlContent = 'html content for' . __FUNCTION__;
NotificationsUtil::submit($message, $rules);
$this->assertEquals($initialNotificationCount, Notification::getCount());
$this->assertEquals($initialEmailMessageCount, EmailMessage::getCount());
}
示例8: testAsynchronousDownloadDefaultControllerActions
/**
* Walkthrough test for synchronous download
*/
public function testAsynchronousDownloadDefaultControllerActions()
{
$super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$notificationsBeforeCount = Notification::getCount();
$notificationMessagesBeforeCount = NotificationMessage::getCount();
$products = Product::getAll();
if (count($products)) {
foreach ($products as $product) {
$product->delete();
}
}
$products = array();
for ($i = 0; $i <= ExportModule::$asynchronousThreshold + 1; $i++) {
$products[] = ProductTestHelper::createProductByNameForOwner('superProduct' . $i, $super);
}
$this->setGetArray(array('Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '1', 'selectedIds' => ''));
$this->runControllerWithRedirectExceptionAndGetUrl('products/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('products', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
$this->assertEquals($notificationMessagesBeforeCount + 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::getAll();
if (count($exportItems)) {
foreach ($exportItems as $exportItem) {
$exportItem->delete();
}
}
$selectedIds = "";
foreach ($products as $product) {
$selectedIds .= $product->id . ",";
// Not Coding Standard
}
$this->setGetArray(array('ProductsSearchForm' => array('anyMixedAttributesScope' => array(0 => 'All'), 'anyMixedAttributes' => '', 'quantity' => ''), 'multiselect_ProductsSearchForm_anyMixedAttributesScope' => 'All', 'Product_page' => '1', 'export' => '', 'ajax' => '', 'selectAll' => '', 'selectedIds' => "{$selectedIds}"));
$this->runControllerWithRedirectExceptionAndGetUrl('products/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('products', $exportItems[0]->exportFileName);
$this->assertTrue($fileModel instanceof ExportFileModel);
$this->assertEquals($notificationsBeforeCount + 1, Notification::getCount());
$this->assertEquals($notificationMessagesBeforeCount + 1, NotificationMessage::getCount());
}
示例9: testResolveEmailInvitesByPeople
/**
* @depends testResolveConversationParticipants
*/
public function testResolveEmailInvitesByPeople()
{
$this->assertEquals(0, Notification::getCount());
$this->assertEquals(0, EmailMessage::getCount());
$super = Yii::app()->user->userModel;
$super->primaryEmail->emailAddress = 'super@zurmo.com';
NotificationTestHelper::setNotificationSettingsForUser($super, 'ConversationInvites');
$jack = User::getByUsername('jack');
$jack->primaryEmail->emailAddress = 'jack@zurmo.com';
NotificationTestHelper::setNotificationSettingsForUser($jack, 'ConversationInvites', true, false);
$steven = User::getByUsername('steven');
$steven->primaryEmail->emailAddress = 'steven@zurmo.com';
NotificationTestHelper::setNotificationSettingsForUser($steven, 'ConversationInvites', false, true);
$mary = User::getByUsername('mary');
$mary->primaryEmail->emailAddress = 'mary@zurmo.com';
NotificationTestHelper::setNotificationSettingsForUser($mary, 'ConversationInvites', false, false);
$conversation = new Conversation();
$conversation->owner = $super;
$conversation->subject = 'Test Resolve Conversation Participants';
$conversation->description = 'This is for testing conversation participants.';
$this->assertTrue($conversation->save());
ConversationParticipantsUtil::resolveEmailInvitesByPeople($conversation, array($super, $jack, $steven, $mary));
$this->assertEquals(2, Notification::getCount());
$notifications = Notification::getAll();
$this->assertContains('<h2 class="h2">Join the Conversation</h2>Clark Kent would like you to join a conversation <strong>"Test Resolve Conversation Participants"</strong><br/>', $notifications[0]->notificationMessage->htmlContent);
$this->assertContains('Clark Kent would like you to join a conversation "Test Resolve Conversation Participants"', $notifications[0]->notificationMessage->textContent);
$this->assertEquals(2, EmailMessage::getCount());
$emailMessages = EmailMessage::getAll();
$this->assertContains('<h2 class="h2">Join the Conversation</h2>Clark Kent would like you to join a conversation <strong>"Test Resolve Conversation Participants"</strong><br/>', $emailMessages[0]->content->htmlContent);
$this->assertContains('Powered By <a href="http://www.zurmo.com">Zurmo</a>', $emailMessages[0]->content->htmlContent);
$this->assertContains('Clark Kent would like you to join a conversation "Test Resolve Conversation Participants"', $emailMessages[0]->content->textContent);
$this->assertContains('Manage your email preferences', $emailMessages[0]->content->textContent);
$this->assertEquals('You have been invited to participate in a conversation', $emailMessages[0]->subject);
}
示例10: testTaskStatusBecomesRejectedNotificationWhenOwnerIsCurrentUser
public function testTaskStatusBecomesRejectedNotificationWhenOwnerIsCurrentUser()
{
$task = new Task();
$task->name = 'Reject Task';
$task->requestedByUser = self::$sally;
$task->owner = Yii::app()->user->userModel;
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Notification::getCount());
$this->assertTrue($task->save());
//Now change status
$task->status = Task::STATUS_REJECTED;
$this->assertTrue($task->save());
//No emails should be queued up
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Notification::getCount());
}
示例11: testAddingCommentsAndUpdatingActivityStampsOnMission
/**
* @depends testSuperUserCreateMission
*/
public function testAddingCommentsAndUpdatingActivityStampsOnMission()
{
if (!SECURITY_OPTIMIZED) {
return;
}
$this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
$missions = Mission::getAll();
$this->assertEquals(1, count($missions));
$this->assertEquals(0, $missions[0]->comments->count());
$this->assertEquals(2, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
$this->assertEquals(2, Notification::getCount());
$oldStamp = $missions[0]->latestDateTime;
//Validate comment
$this->setGetArray(array('relatedModelId' => $missions[0]->id, 'relatedModelClassName' => 'Mission', 'relatedModelRelationName' => 'comments', 'redirectUrl' => 'someRedirect'));
$this->setPostArray(array('ajax' => 'comment-inline-edit-form', 'Comment' => array('description' => 'a ValidComment Name')));
$content = $this->runControllerWithExitExceptionAndGetContent('comments/default/inlineCreateSave');
$this->assertEquals('[]', $content);
//Now save that comment.
sleep(2);
//to force some time to pass.
$this->setGetArray(array('relatedModelId' => $missions[0]->id, 'relatedModelClassName' => 'Mission', 'relatedModelRelationName' => 'comments', 'redirectUrl' => 'someRedirect'));
$this->setPostArray(array('Comment' => array('description' => 'a ValidComment Name')));
$content = $this->runControllerWithRedirectExceptionAndGetContent('comments/default/inlineCreateSave');
$id = $missions[0]->id;
$missions[0]->forget();
$mission = Mission::getById($id);
$this->assertEquals(1, $mission->comments->count());
//should update latest activity stamp
$this->assertNotEquals($oldStamp, $missions[0]->latestDateTime);
$newStamp = $missions[0]->latestDateTime;
sleep(2);
// Sleeps are bad in tests, but I need some time to pass
//Mary should be able to add a comment because everyone can do this on a mission
$mary = $this->logoutCurrentUserLoginNewUserAndGetByUsername('mary');
$this->setGetArray(array('relatedModelId' => $missions[0]->id, 'relatedModelClassName' => 'Mission', 'relatedModelRelationName' => 'comments', 'redirectUrl' => 'someRedirect'));
$this->setPostArray(array('Comment' => array('description' => 'a ValidComment Name 2')));
$content = $this->runControllerWithRedirectExceptionAndGetContent('comments/default/inlineCreateSave');
$id = $missions[0]->id;
$missions[0]->forget();
$mission = Mission::getById($id);
$this->assertEquals(2, $mission->comments->count());
$this->assertNotEquals($newStamp, $mission->latestDateTime);
}
示例12: testRunAndProcessStuckJobs
public function testRunAndProcessStuckJobs()
{
Yii::app()->user->userModel = User::getByUsername('super');
$emailAddress = new Email();
$emailAddress->emailAddress = 'sometest@zurmoalerts.com';
Yii::app()->user->userModel->primaryEmail = $emailAddress;
$saved = Yii::app()->user->userModel->save();
$this->assertTrue($saved);
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
$monitorJob = new MonitorJob();
$this->assertEquals(0, JobInProcess::getCount());
$this->assertEquals(0, StuckJob::getCount());
$this->assertEquals(0, Notification::getCount());
$this->assertEquals(0, EmailMessage::getCount());
$jobInProcess = new JobInProcess();
$jobInProcess->type = 'Test';
$this->assertTrue($jobInProcess->save());
//Should make createdDateTime long enough in past to trigger as stuck.
$createdDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 10000);
$sql = "Update item set createddatetime = '" . $createdDateTime . "' where id = " . $jobInProcess->getClassId('Item');
ZurmoRedBean::exec($sql);
$jobInProcess->forget();
$monitorJob->run();
$this->assertEquals(0, JobInProcess::getCount());
//should still be 0 but the quantity should increase
$this->assertEquals(0, Notification::getCount());
//There should now be one stuck job with quantity 1
$stuckJobs = StuckJob::getAll();
$this->assertEquals(1, count($stuckJobs));
$this->assertEquals('Test', $stuckJobs[0]->type);
$this->assertEquals(1, $stuckJobs[0]->quantity);
//Now it should increase to 2
$jobInProcess = new JobInProcess();
$jobInProcess->type = 'Test';
$this->assertTrue($jobInProcess->save());
//Should make createdDateTime long enough in past to trigger as stuck.
$createdDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 10000);
$sql = "Update item set createddatetime = '" . $createdDateTime . "' where id = " . $jobInProcess->getClassId('Item');
ZurmoRedBean::exec($sql);
$jobInProcess->forget();
$monitorJob->run();
$this->assertEquals(0, JobInProcess::getCount());
//should still be 0 but the quantity should increase
$this->assertEquals(0, Notification::getCount());
//There should now be one stuck job with quantity 1
$stuckJobs = StuckJob::getAll();
$this->assertEquals(1, count($stuckJobs));
$this->assertEquals('Test', $stuckJobs[0]->type);
$this->assertEquals(2, $stuckJobs[0]->quantity);
//Set quantity to 3, then run monitor again and notification should go out.
$stuckJobs[0]->quantity = 3;
$this->assertTrue($stuckJobs[0]->save());
$jobInProcess = new JobInProcess();
$jobInProcess->type = 'Test';
$this->assertTrue($jobInProcess->save());
//Should make createdDateTime long enough in past to trigger as stuck.
$createdDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time() - 10000);
$sql = "Update item set createddatetime = '" . $createdDateTime . "' where id = " . $jobInProcess->getClassId('Item');
ZurmoRedBean::exec($sql);
$jobInProcess->forget();
//Now the threshold of 4 should be reached and we should send a notification
$monitorJob->run();
ForgetAllCacheUtil::forgetAllCaches();
$stuckJobs = StuckJob::getAll();
$this->assertEquals(1, count($stuckJobs));
$this->assertEquals('Test', $stuckJobs[0]->type);
$this->assertEquals(4, $stuckJobs[0]->quantity);
$this->assertEquals(1, Notification::getCount());
//Confirm an email was sent
$this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
$this->assertEquals(1, EmailMessage::getCount());
$this->assertEquals(1, Yii::app()->emailHelper->getSentCount());
}
示例13: testNewNotificationWhenProjectIsArchived
public function testNewNotificationWhenProjectIsArchived()
{
$project = new Project();
$project->name = 'project-' . __FUNCTION__;
$project->owner = self::$steve;
$project->status = Project::STATUS_ARCHIVED;
$this->assertEquals(0, EmailMessage::getCount());
$this->assertEquals(0, Notification::getCount());
ProjectsNotificationUtil::submitProjectNotificationMessage($project, ProjectAuditEvent::PROJECT_ARCHIVED);
$emailMessages = EmailMessage::getAll();
$notifications = Notification::getAll();
$this->assertCount(1, $emailMessages);
$this->assertCount(1, $notifications);
$this->assertEquals('PROJECT: project-' . __FUNCTION__, $emailMessages[0]->subject);
$this->assertContains("The project, 'project-" . __FUNCTION__ . "', is now archived.", $emailMessages[0]->content->textContent);
$this->assertContains("The project, 'project-" . __FUNCTION__ . "', is now archived.", $emailMessages[0]->content->htmlContent);
$this->assertContains("The project, 'project-" . __FUNCTION__ . "', is now archived.", $notifications[0]->notificationMessage->textContent);
$this->assertContains("The project, 'project-" . __FUNCTION__ . "', is now archived.", $notifications[0]->notificationMessage->htmlContent);
}
示例14: testGetCountByTypeAndUser
/**
* @depends testNotificationMessage
*/
public function testGetCountByTypeAndUser()
{
$super = User::getByUsername('super');
$billy = User::getByUsername('billy');
Yii::app()->user->userModel = $super;
$this->assertEquals(0, Notification::getCount());
$notification = new Notification();
$notification->type = 'Simple';
$notification->owner = $super;
$this->assertTrue($notification->save());
$notification = new Notification();
$notification->type = 'Simple';
$notification->owner = $super;
$this->assertTrue($notification->save());
//There are 2 notifications
$this->assertEquals(2, Notification::getCount());
//And 0 notifications unread for billy
$this->assertEquals(0, Notification::getCountByTypeAndUser('Simple', $billy));
//Now add another super notification, but not simple.
$notification = new Notification();
$notification->type = 'Simple2Test';
$notification->owner = $super;
$this->assertTrue($notification->save());
//And there are still 2 notifications for super
$this->assertEquals(2, Notification::getCountByTypeAndUser('Simple', $super));
//Add a notification for billy.
$notification = new Notification();
$notification->type = 'Simple';
$notification->owner = $billy;
$this->assertTrue($notification->save());
//And there is still 1 unread notification for billy
$this->assertEquals(1, Notification::getCountByTypeAndUser('Simple', $billy));
}
示例15: count
public function count()
{
$this->set('content', Notification::getCount());
}