Exemplo n.º 1
0
 /**
  * @dataProvider like_notice_provider
  */
 public function test_like_notice($member_id_to, $mc_notice_like, $member_id_from, $is_test_after_read, $is_cahce_deleted_exp, $countup_num, $countup_num_all)
 {
     if (!is_enabled('notice')) {
         \Util_Develop::output_test_info(__FILE__, __LINE__);
         $this->markTestSkipped('notice module is disabled.');
     }
     // 事前準備
     \Model_MemberConfig::set_value($member_id_to, \Notice\Form_MemberConfig::get_name('like'), $mc_notice_like);
     $is_new = false;
     if (!self::$commented_member_id_before || $member_id_to != self::$commented_member_id_before) {
         self::$album_image = \Album\Site_Test::setup_album_image(self::$member_id, null, 1);
         self::$album_image_comment = \Site_Test::save_comment('album_image', self::$album_image->id, $member_id_to);
         $is_new = true;
     }
     self::$commented_member_id_before = $member_id_to;
     if ($is_test_after_read) {
         $read_count = \Notice\Site_Util::change_status2read($member_id_to, self::$foreign_table, self::$album_image_comment->id, self::$type_key);
     }
     $notice_count_all_before = \Notice\Model_Notice::get_count();
     // set cache
     $notice_count_before = \Notice\Site_Util::get_unread_count($member_id_to);
     if (self::$is_check_notice_cache) {
         $this->assertFalse(\Notice\Site_Test::check_no_cache4notice_unread($member_id_to));
     }
     // cache が生成されていることを確認
     // like save
     $is_liked = (bool) Model_AlbumImageCommentLike::change_registered_status4unique_key(array('album_image_comment_id' => self::$album_image_comment->id, 'member_id' => $member_id_from));
     if (self::$is_check_notice_cache) {
         if ($is_cahce_deleted_exp) {
             $this->assertTrue(\Notice\Site_Test::check_no_cache4notice_unread($member_id_to));
         } else {
             $this->assertFalse(\Notice\Site_Test::check_no_cache4notice_unread($member_id_to));
         }
     }
     // notice count 取得
     $notice_count = \Notice\Site_Util::get_unread_count($member_id_to);
     if (self::$is_check_notice_cache) {
         $this->assertFalse(\Notice\Site_Test::check_no_cache4notice_unread($member_id_to));
     }
     // cache が生成されていることを確認
     // execute test
     $this->assertEquals($notice_count_before + $countup_num, $notice_count);
     // count up を確認
     // Model_Notice
     // 件数
     $notice_count_all = \Notice\Model_Notice::get_count();
     $this->assertEquals($notice_count_all_before + $countup_num_all, $notice_count_all);
     // record
     if ($notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$album_image_comment->id, \Notice\Site_Util::get_notice_type(self::$type_key))) {
         $notice_status = \Notice\Model_NoticeStatus::get4member_id_and_notice_id($member_id_to, $notice->id);
         $notice_member_from = \Notice\Model_NoticeMemberFrom::get_last();
         if ($mc_notice_like !== 0 && $member_id_to != $member_id_from) {
             $this->assertEquals($member_id_from, $notice_member_from->member_id);
         }
         $this->assertEquals($notice_member_from->created_at, $notice_status->sort_datetime);
     }
 }
Exemplo n.º 2
0
 protected function change_notice_status2read($member_id, $foreign_table, $foreign_id, $type_key = null)
 {
     if ($read_count = \Notice\Site_Util::change_status2read($member_id, $foreign_table, $foreign_id, $type_key)) {
         $this->set_notification_count();
     }
 }
Exemplo n.º 3
0
 /**
  * @dataProvider like_watch_provider
  */
 public function test_like_watch($member_id_to, $member_id_from, $mc_notice_comment, $mc_watch_liked, $member_id_add_comment, $is_countup_watch_exp, $is_created_watch_exp, $notice_countup_num_exp)
 {
     if (!is_enabled('notice')) {
         \Util_Develop::output_test_info(__FILE__, __LINE__);
         $this->markTestSkipped('notice module is disabled.');
     }
     // 事前準備
     \Model_MemberConfig::set_value($member_id_from, \Notice\Form_MemberConfig::get_name('comment'), $mc_notice_comment);
     \Model_MemberConfig::set_value($member_id_from, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), $mc_watch_liked);
     $is_new = false;
     if ($member_id_to != self::$member_id) {
         self::$member_id = $member_id_to;
         self::set_note();
         $is_new = true;
     }
     $note_id = self::$note_id;
     $foreign_id = self::$note_id;
     $watch_count_all_before = \Notice\Model_MemberWatchContent::get_count();
     // 既読処理
     $read_count = \Notice\Site_Util::change_status2read($member_id_from, self::$foreign_table, $note_id, self::$type_key);
     // like save
     $like_id = Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => $member_id_from));
     self::$liked_member_id_before = $member_id_from;
     // Model_Notice
     $member_watch_content = \Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $foreign_id, $member_id_from);
     if ($is_created_watch_exp) {
         $this->assertNotNull($member_watch_content);
     } else {
         $this->assertNull($member_watch_content);
     }
     // 件数
     $watch_count_all = \Notice\Model_MemberWatchContent::get_count();
     $watch_count_all_countup_num = $is_countup_watch_exp ? 1 : 0;
     $this->assertEquals($watch_count_all_before + $watch_count_all_countup_num, $watch_count_all);
     // set cache
     $notice_count_before = \Notice\Site_Util::get_unread_count($member_id_from);
     // note_comment save
     $note_comment_added = self::save_comment($member_id_add_comment);
     // notice count を取得
     $notice_count = \Notice\Site_Util::get_unread_count($member_id_from);
     // execute test
     $this->assertEquals($notice_count_before + $notice_countup_num_exp, $notice_count);
     // count up を確認
 }