protected function setUp() { if (!($this->files = \Model_FileTmp::find('all'))) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('No data.'); } }
/** * @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::$timeline = Site_Test::setup_timeline(self::$member_id); self::$timeline_comment = \Site_Test::save_comment('timeline', self::$timeline->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::$timeline_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_TimelineCommentLike::change_registered_status4unique_key(array('timeline_comment_id' => self::$timeline_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::$timeline_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); } }
public function test_check_file_size() { if ($this->is_save_db) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('File is saved in db.'); } foreach ($this->files as $file) { $test = File::get_size(self::check_and_get_file_path($file->path, $file->name)); $this->assertEquals($file->filesize, $test); } }
public function test_timeline_exists() { if (!($list = Model_TimelineCache::find('all'))) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('No record for test.'); } foreach ($list as $obj) { // test for cache exists. $timelines = Model_Timeline::check_authority($obj->timeline_id); $this->assertNotEmpty($timelines); } }
public function test_check_real_file_tmp_info() { $raw_file_dir_path = conf('upload.types.img.tmp.raw_file_path'); if (!file_exists($raw_file_dir_path) || !($file_paths = Util_file::get_file_recursive($raw_file_dir_path))) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('No data.'); } foreach ($file_paths as $file_path) { $this->check_real_file_tmp_info($file_path); } if (!($file_paths = Util_file::get_file_recursive(conf('upload.types.file.tmp.raw_file_path')))) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped('No data.'); } foreach ($file_paths as $file_path) { $this->check_real_file_tmp_info($file_path); } }
public function test_delete_with_relations() { if (!($album = $this->get_album())) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped(); } $album_id = $album->id; $member_id = $album->member_id; $album_filesize_total = self::get_album_filesize_total($album_id); $member_filesize_before = self::get_member_filesize_total($member_id); $album->delete(); // 件数 // album $this->assertEquals(self::$album_count - 1, \Util_Orm::get_count_all('\\Album\\Model_Album')); // album_image $album_images = Model_AlbumImage::get4album_id($album_id); $this->assertEmpty($album_images); // filesize $this->assertEquals($member_filesize_before - $album_filesize_total, self::get_member_filesize_total($member_id)); // timeline if (is_enabled('timeline')) { $this->assertEquals(self::$timeline_count - 1, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline')); $this->assertEquals(self::$timeline_cache_count - 2, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache')); $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('album', $album_id, \Config::get('timeline.types.album')); $this->assertEmpty($timelines); } }
/** * @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 を確認 }
/** * @dataProvider update_public_flag_provider */ public function test_update_public_flag($default_public_flag, $public_flag, $timeline_public_flag_expected) { if (!self::$album_image || !is_null($default_public_flag)) { self::$album_image = $this->get_album_image(array('public_flag' => $default_public_flag), 2); } $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('album', self::$album_image->album_id, \Config::get('timeline.types.album_image')); $timeline_before = array_shift($timelines); // timeline view cache 作成 if (self::$is_check_timeline_view_cache) { $timeline_view_cache_before = \Timeline\Site_Util::make_view_cache4foreign_table_and_foreign_id('album', $album->id, \Config::get('timeline.types.album_image')); } $before = array('public_flag' => self::$album_image->public_flag, 'created_at' => self::$album_image->created_at, 'updated_at' => self::$album_image->updated_at); // update public_flag \Util_Develop::sleep(); self::$album_image->update_public_flag($public_flag); $is_updated = $public_flag != $before['public_flag']; // 値 $this->assertEquals($public_flag, self::$album_image->public_flag); // date // 変更あり if ($is_updated) { $this->assertTrue(\Util_Date::check_is_future(self::$album_image->updated_at, $before['updated_at'])); } else { $this->assertEquals($before['updated_at'], self::$album_image->updated_at); } // timeline if (is_enabled('timeline')) { // 件数 $this->assertEquals(self::$timeline_count, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline')); $this->assertEquals(self::$timeline_cache_count, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache')); $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('album', self::$album_image->album_id, \Config::get('timeline.types.album_image')); $timeline = array_shift($timelines); $this->assertEquals($timeline_public_flag_expected, $timeline->public_flag); // 変更あり if ($is_updated) { if (\Site_Util::check_is_expanded_public_flag_range($before['public_flag'], $public_flag)) { $this->assertTrue(\Util_Date::check_is_future($timeline->sort_datetime, self::$album_image->created_at)); } } else { $this->assertEquals($timeline_before->updated_at, $timeline->updated_at); } // timeline view cache check if (self::$is_check_timeline_view_cache) { $this->assertEmpty(\Timeline\Site_Util::get_view_cache($timeline->id)); } } }
/** * @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); }