Esempio n. 1
0
 public function test_delete_notice()
 {
     // 事前準備
     $config_type_key = 'like';
     \Model_MemberConfig::set_value(1, \Notice\Form_MemberConfig::get_name('comment'), 0);
     \Model_MemberConfig::set_value(2, \Notice\Form_MemberConfig::get_name($config_type_key), 1);
     \Model_MemberConfig::set_value(2, \Notice\Site_Util::get_member_config_name_for_watch_content('comment'), 0);
     self::$member_id = 1;
     $note = self::set_note();
     $note_comment = self::save_comment(self::$note_id, 2);
     self::$note_comment_id = $note_comment->id;
     $note_id = self::$note_id;
     $foreign_id = self::$note_comment_id;
     $notice_count_all_before = \Notice\Model_Notice::get_count();
     $notice_status_count_all_before = \Notice\Model_NoticeStatus::get_count();
     $notice_member_from_count_all_before = \Notice\Model_NoticeMemberFrom::get_count();
     // イイね実行
     $is_liked = (bool) Model_NoteCommentLike::change_registered_status4unique_key(array('note_comment_id' => self::$note_comment_id, 'member_id' => 4));
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $foreign_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // 件数確認
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 1, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 1, \Notice\Model_NoticeMemberFrom::get_count());
     // 関連テーブルのレコードが作成されていることを確認
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 4));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $foreign_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // イイねを取り消し
     $is_liked = (bool) Model_NoteCommentLike::change_registered_status4unique_key(array('note_comment_id' => self::$note_comment_id, 'member_id' => 4));
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 4));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $foreign_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // イイね実行
     $is_liked = (bool) Model_NoteCommentLike::change_registered_status4unique_key(array('note_comment_id' => self::$note_comment_id, 'member_id' => 4));
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $foreign_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // note_comment 削除
     $note_comment->delete();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     // 再度 comment 投稿
     $note_comment = self::save_comment(self::$note_id, 2);
     self::$note_comment_id = $note_comment->id;
     // イイね実行
     $is_liked = (bool) Model_NoteCommentLike::change_registered_status4unique_key(array('note_comment_id' => self::$note_comment_id, 'member_id' => 4));
     // 件数確認
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 1, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 1, \Notice\Model_NoticeMemberFrom::get_count());
     // note 削除
     $note->delete_with_relations();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 4));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $foreign_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
 }
Esempio n. 2
0
 public function test_delete_notice()
 {
     // 事前準備
     \Model_MemberConfig::set_value(2, \Notice\Form_MemberConfig::get_name(self::$type_key), 1);
     \Model_MemberConfig::set_value(2, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), 1);
     \Model_MemberConfig::set_value(3, \Notice\Form_MemberConfig::get_name(self::$type_key), 1);
     \Model_MemberConfig::set_value(3, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), 1);
     self::$member_id = 1;
     self::set_note();
     $note_id = self::$note_id;
     $foreign_id = self::$note_id;
     $notice_count_all_before = \Notice\Model_Notice::get_count();
     $notice_status_count_all_before = \Notice\Model_NoticeStatus::get_count();
     $notice_member_from_count_all_before = \Notice\Model_NoticeMemberFrom::get_count();
     $member_watch_content_count_all_before = \Notice\Model_MemberWatchContent::get_count();
     // 他人がイイね
     $like_id = Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => 2));
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // 件数確認
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 1, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 1, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが作成されていることを確認
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $note_id, 2));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // イイねを取り消し
     $like_id = Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => 2));
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // watch は解除されない
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $note_id, 2));
     // watch は解除されない
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // 他人のイイね+自分がコメント
     $note_like_id = Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => 2));
     self::save_comment(1, 'Test comment1.');
     $notice_like = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $notice_comment = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type('comment'));
     $this->assertNotNull($notice_like);
     $this->assertNotNull($notice_comment);
     // 件数確認
     $this->assertEquals($notice_count_all_before + 2, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 2, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 2, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが作成されていることを確認
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice_comment->id));
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice_like->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice_like->id, 2));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice_comment->id, self::$member_id));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $note_id, 2));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $note_id, self::$member_id));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // イイねを取り消し
     $like_id = Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => 2));
     // 件数確認
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 1, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 1, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // watch は解除されない
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice_comment->id));
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice_like->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice_like->id, 2));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice_comment->id, self::$member_id));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $note_id, 2));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $note_id, self::$member_id));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // 他人がイイね
     $note_like_id = Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => 3));
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // note 削除
     $note = Model_Note::find($note_id);
     $note->delete_with_relations();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 3));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $note_id, 3));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $note_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
 }
Esempio n. 3
0
 public function test_delete_notice()
 {
     // prepare test
     \Model_MemberConfig::set_value(1, \Notice\Form_MemberConfig::get_name('comment'), 1);
     \Model_MemberConfig::set_value(2, \Notice\Form_MemberConfig::get_name(self::$type_key), 1);
     \Model_MemberConfig::set_value(2, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), 1);
     \Model_MemberConfig::set_value(3, \Notice\Form_MemberConfig::get_name(self::$type_key), 1);
     \Model_MemberConfig::set_value(3, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), 1);
     $notice_count_all_before = \Notice\Model_Notice::get_count();
     $notice_status_count_all_before = \Notice\Model_NoticeStatus::get_count();
     $notice_member_from_count_all_before = \Notice\Model_NoticeMemberFrom::get_count();
     $member_watch_content_count_all_before = \Notice\Model_MemberWatchContent::get_count();
     self::$member_id = 1;
     self::$album_image = self::set_album_image();
     $foreign_id = self::$album_image->id;
     $album_image_id = self::$album_image->id;
     // 他人がコメント
     $album_image_comment = $this->save_comment(2, 'Test comment1.');
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // 件数確認
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 1, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 1, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが作成されていることを確認
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 2));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // コメントを削除
     $album_image_comment->delete();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // keep watch count
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 2));
     // keep watch count
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // 自分もコメント
     $album_image_comment = $this->save_comment(2, 'Test comment2-2.');
     $this->save_comment(1, 'Test comment1.');
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // 件数確認
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 2, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 2, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが作成されていることを確認
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, self::$member_id));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 2));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // コメントを削除
     $album_image_comment->delete();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // watch は解除されない
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice->id));
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, self::$member_id));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 2));
     // watch は解除されない
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // 他人がコメント
     $album_image_comment = $this->save_comment(3, 'Test comment1.');
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // delete album_image
     $album_image = Model_AlbumImage::find($album_image_id);
     $album_image->delete();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 3));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 3));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // album delete test
     // setup
     self::$album_image = self::set_album_image(null, 1, self::$album->id);
     $foreign_id = self::$album_image->id;
     $album_image_id = self::$album_image->id;
     // comment athers
     $album_image_comment = $this->save_comment(3, 'Test comment1.');
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // delete album_image
     self::$album->delete();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 3));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 3));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
 }
Esempio n. 4
0
 public function test_delete_notice()
 {
     // 事前準備
     \Model_MemberConfig::set_value(2, \Notice\Form_MemberConfig::get_name(self::$type_key), 1);
     \Model_MemberConfig::set_value(2, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), 1);
     \Model_MemberConfig::set_value(3, \Notice\Form_MemberConfig::get_name(self::$type_key), 1);
     \Model_MemberConfig::set_value(3, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), 1);
     self::$member_id = 1;
     self::$album_image = \Album\Site_Test::setup_album_image(self::$member_id, null, 1);
     self::$album = Model_Album::find(self::$album_image->album_id);
     $album_image_id = self::$album_image->id;
     $foreign_id = self::$album_image->id;
     $notice_count_all_before = \Notice\Model_Notice::get_count();
     $notice_status_count_all_before = \Notice\Model_NoticeStatus::get_count();
     $notice_member_from_count_all_before = \Notice\Model_NoticeMemberFrom::get_count();
     $member_watch_content_count_all_before = \Notice\Model_MemberWatchContent::get_count();
     // liked from others.
     $like_id = Model_AlbumImageLike::change_registered_status4unique_key(array('album_image_id' => $album_image_id, 'member_id' => 2));
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // check count
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 1, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 1, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // check created related table records.
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 2));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // undo like.
     $like_id = Model_AlbumImageLike::change_registered_status4unique_key(array('album_image_id' => $album_image_id, 'member_id' => 2));
     // check count
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // keep watched
     // check deleted related table records.
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 2));
     // keep watched
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // others execute like and coment myself.
     $album_image_like_id = Model_AlbumImageLike::change_registered_status4unique_key(array('album_image_id' => $album_image_id, 'member_id' => 2));
     \Site_Test::save_comment('album_image', $album_image_id, 1, 'Test comment1.');
     $notice_like = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $notice_comment = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type('comment'));
     $this->assertNotNull($notice_like);
     $this->assertNotNull($notice_comment);
     // check count
     $this->assertEquals($notice_count_all_before + 2, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 2, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 2, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // check created related table records.
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice_comment->id));
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice_like->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice_like->id, 2));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice_comment->id, self::$member_id));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 2));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, self::$member_id));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // undo like.
     $like_id = Model_AlbumImageLike::change_registered_status4unique_key(array('album_image_id' => $album_image_id, 'member_id' => 2));
     // check count
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 1, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 1, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // keep watch
     // check created related table records.
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice_comment->id));
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice_like->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice_like->id, 2));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice_comment->id, self::$member_id));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 2));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, self::$member_id));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // others execute like.
     $album_image_like_id = Model_AlbumImageLike::change_registered_status4unique_key(array('album_image_id' => $album_image_id, 'member_id' => 3));
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // delete album_image.
     $album_image = Model_AlbumImage::find($album_image_id);
     $album_image->delete();
     // check count
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before, \Notice\Model_MemberWatchContent::get_count());
     // check deleted related table records.
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 3));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 3));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // album delete test
     // setup
     self::$album_image = \Album\Site_Test::setup_album_image(self::$member_id, null, 1, self::$album->id);
     $foreign_id = self::$album_image->id;
     $album_image_id = self::$album_image->id;
     // others execute like.
     $album_image_like_id = Model_AlbumImageLike::change_registered_status4unique_key(array('album_image_id' => $album_image_id, 'member_id' => 4));
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // delete album_image
     self::$album->delete();
     // check count
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before, \Notice\Model_MemberWatchContent::get_count());
     // check deleted related table records.
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 3));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, $album_image_id, 3));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, $album_image_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
 }
Esempio n. 5
0
 public function test_delete_notice()
 {
     // 事前準備
     \Model_MemberConfig::set_value(1, \Notice\Form_MemberConfig::get_name('comment'), 1);
     \Model_MemberConfig::set_value(2, \Notice\Form_MemberConfig::get_name(self::$type_key), 1);
     \Model_MemberConfig::set_value(2, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), 1);
     \Model_MemberConfig::set_value(3, \Notice\Form_MemberConfig::get_name(self::$type_key), 1);
     \Model_MemberConfig::set_value(3, \Notice\Site_Util::get_member_config_name_for_watch_content(self::$type_key), 1);
     self::$member_id = 1;
     self::set_timeline();
     $timeline_id = self::$timeline_id;
     $foreign_id = self::$timeline_id;
     $notice_count_all_before = \Notice\Model_Notice::get_count();
     $notice_status_count_all_before = \Notice\Model_NoticeStatus::get_count();
     $notice_member_from_count_all_before = \Notice\Model_NoticeMemberFrom::get_count();
     $member_watch_content_count_all_before = \Notice\Model_MemberWatchContent::get_count();
     // 他人がコメント
     $timeline_comment = self::save_comment(2, 'Test comment1.');
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // 件数確認
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 1, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 1, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが作成されていることを確認
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, self::$timeline_id, 2));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // コメントを削除
     $timeline_comment->delete();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // watch は解除されない
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, self::$timeline_id, 2));
     // watch は解除されない
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // 自分もコメント
     $timeline_comment = self::save_comment(2, 'Test comment2-2.');
     self::save_comment(1, 'Test comment1.');
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // 件数確認
     $this->assertEquals($notice_count_all_before + 1, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before + 2, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before + 2, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが作成されていることを確認
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNotNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, self::$member_id));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, self::$timeline_id, 2));
     $this->assertNotNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // コメントを削除
     $timeline_comment->delete();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before + 1, \Notice\Model_MemberWatchContent::get_count());
     // watch は解除されない
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(2, $notice->id));
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 2));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, self::$member_id));
     $this->assertNotNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, self::$timeline_id, 2));
     // watch は解除されない
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
     // 他人がコメント
     $timeline_comment = self::save_comment(3, 'Test comment1.');
     $notice = \Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_id, \Notice\Site_Util::get_notice_type(self::$type_key));
     $this->assertNotNull($notice);
     // timeline 削除
     $timeline = Model_Timeline::find($timeline_id);
     $timeline->delete();
     // 件数確認
     $this->assertEquals($notice_count_all_before, \Notice\Model_Notice::get_count());
     $this->assertEquals($notice_status_count_all_before, \Notice\Model_NoticeStatus::get_count());
     $this->assertEquals($notice_member_from_count_all_before, \Notice\Model_NoticeMemberFrom::get_count());
     $this->assertEquals($member_watch_content_count_all_before, \Notice\Model_MemberWatchContent::get_count());
     // 関連テーブルのレコードが削除されていることを確認
     $this->assertNull(\Notice\Model_NoticeStatus::get4member_id_and_notice_id(self::$member_id, $notice->id));
     $this->assertNull(\Notice\Model_NoticeMemberFrom::get4notice_id_and_member_id($notice->id, 3));
     $this->assertNull(\Notice\Model_MemberWatchContent::get_one4foreign_data_and_member_id(self::$foreign_table, self::$timeline_id, 3));
     $this->assertNull(\Notice\Model_Notice::get_last4foreign_data(self::$foreign_table, self::$timeline_id, \Notice\Site_Util::get_notice_type(self::$type_key)));
 }