当前位置: 首页>>代码示例>>PHP>>正文


PHP Notification::getById方法代码示例

本文整理汇总了PHP中Notification::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Notification::getById方法的具体用法?PHP Notification::getById怎么用?PHP Notification::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Notification的用法示例。


在下文中一共展示了Notification::getById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testReadUnread

 public function testReadUnread()
 {
     $super = User::getByUsername('super');
     $billy = User::getByUsername('billy');
     Yii::app()->user->userModel = $super;
     $this->deleteAllNotifications();
     $createdNotification = $this->createAndSaveNewNotificationForUser($super);
     $this->assertEquals(1, $this->rules->getUnreadCountForCurrentUser(), 0);
     $savedNotification = Notification::getById($createdNotification->id);
     $savedNotification->ownerHasReadLatest = 0;
     $savedNotification->save();
     $this->assertEquals(1, $this->rules->getUnreadCountForCurrentUser(), 0);
     //Other users should have 0 unread notifications
     Yii::app()->user->userModel = $billy;
     $this->assertEquals(0, $this->rules->getUnreadCountForCurrentUser(), 0);
     //Mark notification as ready by super
     $this->rules->resolveMarkRead($createdNotification->id);
     Yii::app()->user->userModel = $super;
     $this->assertTrue((bool) $savedNotification->ownerHasReadLatest);
     $this->assertTrue((bool) $this->rules->hasCurrentUserReadLatest($createdNotification->id));
     $this->rules->resolveMarkUnread($createdNotification->id);
     $savedNotification = Notification::getById($createdNotification->id);
     $this->assertFalse((bool) $savedNotification->ownerHasReadLatest);
     $this->assertFalse((bool) $this->rules->hasCurrentUserReadLatest($createdNotification->id));
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:25,代码来源:NotificationsMashableInboxRulesTest.php

示例2: resolveRowHtmlOptionsExpression

 public static function resolveRowHtmlOptionsExpression($grid, $row, $data)
 {
     $notification = Notification::getById($data->id);
     if (!$notification->ownerHasReadLatest) {
         $params = array("class" => 'unread');
         return $params;
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:8,代码来源:NotificationsForUserListView.php

示例3: testNotification

 /**
  * @depends testGetCountByUser
  */
 public function testNotification()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $notification = new Notification();
     $notification->type = 'Simple';
     $notification->owner = Yii::app()->user->userModel;
     $this->assertTrue($notification->save());
     $this->assertTrue($notification->save());
     $notificationId = $notification->id;
     $notification->forget();
     //Retrieve again.
     $notification = Notification::getById($notificationId);
     $this->assertEquals('Simple', $notification->type);
     $notification->delete();
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:18,代码来源:NotificationTest.php

示例4: testDeleteByTypeAndUser

 /**
  * @depends testRelationsBetweenNotificationAndNotificationMessage
  */
 public function testDeleteByTypeAndUser()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $joe = UserTestHelper::createBasicUser('joe');
     $sally = UserTestHelper::createBasicUser('sally');
     //Make sure the relations between Notification and NotificationMessage is working.
     $message = new NotificationMessage();
     $message->textContent = 'text content3';
     $message->htmlContent = 'html content3';
     $this->assertTrue($message->save());
     $notification1 = new Notification();
     $notification1->type = 'SimpleDTest';
     $notification1->owner = $joe;
     $notification1->notificationMessage = $message;
     $this->assertTrue($notification1->save());
     //And Billy can create a notification for super
     $notification2 = new Notification();
     $notification2->type = 'SimpleDTest';
     $notification2->owner = $sally;
     $notification2->notificationMessage = $message;
     $this->assertTrue($notification2->save());
     $this->assertEquals(2, $message->notifications->count());
     $messageId = $message->id;
     $notification1Id = $notification1->id;
     $notification2Id = $notification2->id;
     $message->forget();
     $notification1->forget();
     $notification2->forget();
     Notification::deleteByTypeAndUser('SimpleDTest', $joe);
     // Notification message should exist, because there is still notification point to it
     $message = NotificationMessage::getById($messageId);
     $this->assertTrue($message instanceof NotificationMessage);
     $notification2 = Notification::getById($notification2Id);
     $this->assertTrue($notification2 instanceof Notification);
     $notifications = Notification::getByNotificationMessageId($messageId);
     $this->assertEquals(1, count($notifications));
     $this->assertEquals($notification2Id, $notifications[0]->id);
     try {
         Notification::getById($notification1Id);
         $this->fail();
     } catch (NotFoundException $e) {
     }
     $message->forget();
     $notification2->forget();
     // Now delete second notification, this time notification message should be deleted too
     Notification::deleteByTypeAndUser('SimpleDTest', $sally);
     try {
         NotificationMessage::getById($messageId);
         $this->fail();
     } catch (NotFoundException $e) {
     }
     try {
         Notification::getById($notification2Id);
         $this->fail();
     } catch (NotFoundException $e) {
     }
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:60,代码来源:NotificationTest.php


注:本文中的Notification::getById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。