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


PHP Notification::getCountByUser方法代码示例

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


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

示例1: testGetCountByUser

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

示例2: testMissionNotifications

 /**
  * Test mission notifications
  * @depends testCreateAndGetMissionById
  */
 public function testMissionNotifications()
 {
     $super = User::getByUsername('super');
     $steven = User::getByUsername('steven');
     $this->assertEquals(0, Notification::getCountByUser($super));
     $this->assertEquals(0, Notification::getCountByUser($steven));
     $missions = Mission::getAll();
     $mission = $missions[0];
     $mission->status = Mission::STATUS_TAKEN;
     $this->assertTrue($mission->save());
     $this->assertEquals(1, Notification::getCountByUser($super));
     $this->assertEquals(0, Notification::getCountByUser($steven));
     $mission->status = Mission::STATUS_COMPLETED;
     $this->assertTrue($mission->save());
     $this->assertEquals(2, Notification::getCountByUser($super));
     $this->assertEquals(0, Notification::getCountByUser($steven));
     $mission->status = Mission::STATUS_REJECTED;
     $this->assertTrue($mission->save());
     $this->assertEquals(2, Notification::getCountByUser($super));
     $this->assertEquals(1, Notification::getCountByUser($steven));
     $mission->status = Mission::STATUS_ACCEPTED;
     $this->assertTrue($mission->save());
     $this->assertEquals(2, Notification::getCountByUser($super));
     $this->assertEquals(2, Notification::getCountByUser($steven));
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:29,代码来源:MissionTest.php

示例3: testMissionNotifications

 /**
  * Test mission notifications
  * @depends testCreateAndGetMissionById
  */
 public function testMissionNotifications()
 {
     $super = User::getByUsername('super');
     $super->primaryEmail->emailAddress = 'super@zurmo.com';
     $this->assertTrue($super->save());
     $steven = User::getByUsername('steven');
     //A new mission notification was already created for steven
     $this->assertEquals(0, Notification::getCountByUser($super));
     $this->assertEquals(1, Notification::getCountByUser($steven));
     $this->assertEquals(1, EmailMessage::getCount());
     $missions = Mission::getAll();
     $mission = $missions[0];
     $mission->status = Mission::STATUS_TAKEN;
     $this->assertTrue($mission->save());
     $this->assertEquals(1, Notification::getCountByUser($super));
     $this->assertEquals(1, Notification::getCountByUser($steven));
     $this->assertEquals(2, EmailMessage::getCount());
     $mission->status = Mission::STATUS_COMPLETED;
     $this->assertTrue($mission->save());
     $this->assertEquals(2, Notification::getCountByUser($super));
     $this->assertEquals(1, Notification::getCountByUser($steven));
     $this->assertEquals(3, EmailMessage::getCount());
     $mission->status = Mission::STATUS_REJECTED;
     $this->assertTrue($mission->save());
     $this->assertEquals(2, Notification::getCountByUser($super));
     $this->assertEquals(2, Notification::getCountByUser($steven));
     $this->assertEquals(4, EmailMessage::getCount());
     $mission->status = Mission::STATUS_ACCEPTED;
     $this->assertTrue($mission->save());
     $this->assertEquals(2, Notification::getCountByUser($super));
     $this->assertEquals(3, Notification::getCountByUser($steven));
     $this->assertEquals(5, EmailMessage::getCount());
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:37,代码来源:MissionTest.php


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