/** * @covers markUserHasReadLatest */ public function testMarkUserHasReadLatest() { $super = User::getByUsername('super'); $steven = UserTestHelper::createBasicUser('steven'); $task = new Task(); $task->name = 'MyTest'; $nowStamp = DateTimeUtil::convertTimestampToDbFormatDateTime(time()); $this->assertTrue($task->save()); $task = Task::getById($task->id); $user = Yii::app()->user->userModel; $notificationSubscriber = new NotificationSubscriber(); $notificationSubscriber->person = $steven; $notificationSubscriber->hasReadLatest = false; $task->notificationSubscribers->add($notificationSubscriber); $this->assertTrue($task->save()); $id = $task->id; $task->forget(); unset($task); $task = Task::getById($id); $this->assertEquals(0, $task->notificationSubscribers->offsetGet(0)->hasReadLatest); $this->assertEquals(0, $task->notificationSubscribers->offsetGet(1)->hasReadLatest); //After running for super, nothing will change. TasksUtil::markUserHasReadLatest($task, $steven); TasksUtil::markUserHasReadLatest($task, $super); $id = $task->id; $task->forget(); unset($task); $task = Task::getById($id); foreach ($task->notificationSubscribers as $position => $subscriber) { $this->assertEquals(1, $subscriber->hasReadLatest); } }
protected function processModalDetails(Task $task) { TasksUtil::markUserHasReadLatest($task, Yii::app()->user->userModel); echo ModalEditAndDetailsControllerUtil::setAjaxModeAndRenderModalDetailsView($this, 'TaskModalDetailsView', $task, 'Details'); }