public function executeRead(sfWebRequest $request) { $this->forward400Unless($request['id'], 'id parameter not specified.'); $member = $this->getUser()->getMember(); $ret = opNotificationCenter::setRead($member, $request['id']); if ($ret) { return $this->renderJSON(array('status' => 'success')); } else { $this->forward404('Request parameter id does not exist.'); } }
$t->is(count($notifications), 5); $t->is($notifications[0]['body'], 'notify10'); $t->is($notifications[1]['body'], 'notify9'); $t->is($notifications[2]['body'], 'notify8'); $t->is($notifications[3]['body'], 'notify7'); $t->is($notifications[4]['body'], 'notify6'); $conn->rollback(); //============================================================================== $t->diag('opNotificationCenter::setRead()'); $conn->beginTransaction(); opNotificationCenter::notify($member1, $member2, 'hogehoge1'); opNotificationCenter::notify($member1, $member2, 'hogehoge2'); $notifications = get_notifications($member2); $t->is($notifications[0]['unread'], true); $t->is($notifications[1]['unread'], true); opNotificationCenter::setRead($member2, $notifications[0]['id']); $notifications = get_notifications($member2); $t->is($notifications[0]['unread'], false); $t->is($notifications[1]['unread'], true); $conn->rollback(); //============================================================================== $t->diag('opNotificationCenter::getNotifications()'); $t->info('empty value'); $conn->beginTransaction(); $notifications = opNotificationCenter::getNotifications($member2); $t->ok(is_array($notifications)); $t->is(count($notifications), 0); $conn->rollback(); $t->info('check format'); $conn->beginTransaction(); opNotificationCenter::notify($member1, $member2, 'hogehoge');