/** * @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) { $note = self::set_note(); $note_comment = self::save_comment(self::$note_id, $member_id_to); self::$note_comment_id = $note_comment->id; $is_new = true; } self::$commented_member_id_before = $member_id_to; $note_id = self::$note_id; $foreign_id = self::$note_comment_id; if ($is_test_after_read) { $read_count = \Notice\Site_Util::change_status2read($member_id_to, self::$foreign_table, $foreign_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_NoteCommentLike::change_registered_status4unique_key(array('note_comment_id' => self::$note_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, $foreign_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); } }
/** * @dataProvider mention_provider */ public function test_comment_mention($member_id_from, $mention_member_ids, $countup_nums_exp, $is_cahced_mention_member_ids_exp, $countup_nums_all_exp) { if (!is_enabled('notice')) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('notice module is disabled.'); } // 事前準備 $notice_count_all_before = \Notice\Model_Notice::get_count(); // set cache $notice_counts_before = array(); foreach ($mention_member_ids as $mention_member_id) { $notice_counts_before[$mention_member_id] = \Notice\Site_Util::get_unread_count($mention_member_id); } // timeline_comment save $body = \Site_Test::get_mention_body($mention_member_ids); $timeline = Site_Model::save_timeline($member_id_from, FBD_PUBLIC_FLAG_ALL, 'normal', null, null, $body); $timeline_id = $timeline->id; // check_cache if (self::$is_check_notice_cache) { foreach ($mention_member_ids as $mention_member_id) { if (in_array($mention_member_id, $is_cahced_mention_member_ids_exp)) { $this->assertFalse(\Notice\Site_Test::check_no_cache4notice_unread($mention_member_id)); } else { $this->assertTrue(\Notice\Site_Test::check_no_cache4notice_unread($mention_member_id)); } } } foreach ($mention_member_ids as $mention_member_id) { // notice count 取得 $notice_count = \Notice\Site_Util::get_unread_count($mention_member_id); if (self::$is_check_notice_cache) { $this->assertFalse(\Notice\Site_Test::check_no_cache4notice_unread($mention_member_id)); } // cache が生成されていることを確認 // execute test $this->assertEquals($notice_counts_before[$mention_member_id] + $countup_nums_exp[$mention_member_id], $notice_count); // count up を確認 } // Model_Notice // 件数 $notice_count_all = \Notice\Model_Notice::get_count(); $this->assertEquals($notice_count_all_before + $countup_nums_all_exp, $notice_count_all); }