本文整理汇总了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));
}
示例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));
}
示例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());
}