コード例 #1
0
 /**
  * @dataProvider update_like_provider
  */
 public function test_update_like($member_id)
 {
     $album_image_comment_id = self::$album_image_comment->id;
     // like save
     \Util_Develop::sleep();
     $is_liked = self::execute_like($album_image_comment_id, $member_id);
     $album_image_comment = Model_AlbumImageComment::find($album_image_comment_id);
     $album_image_comment_like = \Util_Orm::get_last_row('\\Album\\Model_AlbumImageCommentLike', array('album_image_comment_id' => $album_image_comment_id));
     // 件数
     $like_count = \Util_Orm::get_count_all('\\Album\\Model_AlbumImageCommentLike', array('album_image_comment_id' => $album_image_comment_id));
     $like_count_expect = $is_liked ? self::$like_count + 1 : self::$like_count - 1;
     $this->assertEquals($like_count_expect, $like_count);
     // 値
     $this->assertEquals($like_count, $album_image_comment->like_count);
     if (!$is_liked) {
         $this->assertNull($album_image_comment_like);
     }
 }
コード例 #2
0
ファイル: notelike.php プロジェクト: uzura8/flockbird
 /**
  * @dataProvider update_like_provider
  */
 public function test_update_post_like($member_id)
 {
     $note_id = self::$note_id;
     $note_before = \DB::select()->from('note')->where('id', $note_id)->execute()->current();
     // note_like save
     \Util_Develop::sleep();
     $is_liked = (bool) Model_NoteLike::change_registered_status4unique_key(array('note_id' => $note_id, 'member_id' => $member_id));
     $note = \DB::select()->from('note')->where('id', $note_id)->execute()->current();
     $note_like = \Util_Orm::get_last_row('\\Note\\Model_NoteLike', array('note_id' => $note_id));
     // 件数
     $like_count = \Util_Orm::get_count_all('\\Note\\Model_NoteLike', array('note_id' => $note_id));
     $like_count_after = $is_liked ? self::$note_like_count + 1 : self::$note_like_count - 1;
     $this->assertEquals($like_count_after, $like_count);
     if (!$is_liked) {
         $this->assertNull($note_like);
     }
     // 値
     $this->assertEquals($like_count, $note['like_count']);
     $this->assertEquals($note_before['sort_datetime'], $note['sort_datetime']);
     // timeline 関連
     if (is_enabled('timeline')) {
         $timeline_id = self::$timeline_id;
         $timeline = \DB::select()->from('timeline')->where('id', $timeline_id)->execute()->current();
         // 値
         $this->assertEquals($like_count, $timeline['like_count']);
         $this->assertEquals(self::$timeline_before->sort_datetime, $timeline['sort_datetime']);
         $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', $timeline_id)->execute();
         foreach ($timeline_caches as $timeline_cache) {
             $this->assertEquals($like_count, $timeline_cache['like_count']);
         }
         //// timeline_cache が最新レコードになっているか
         //$timeline_cache = \Util_Orm::get_last_row('\Timeline\Model_TimelineCache');
         //$this->assertEquals($timeline_id, $timeline_cache->timeline_id);
         // timeline view cache check
         if (self::$is_check_view_cache) {
             try {
                 $timeline_view_cache = \Cache::get(\Timeline\Site_Util::get_cache_key($timeline_id), \Config::get('timeline.articles.cache.expir'));
             } catch (\CacheNotFoundException $e) {
                 $timeline_view_cache = null;
             }
             $this->assertEquals(self::$timeline_view_cache_before, $timeline_view_cache);
         }
     }
 }
コード例 #3
0
ファイル: albumimagelike.php プロジェクト: uzura8/flockbird
 /**
  * @dataProvider update_like_provider
  */
 public function test_update_post_like($member_id)
 {
     $album_image_id = self::$album_image->id;
     $album_image_before = self::$album_image;
     // album_image_like save
     \Util_Develop::sleep();
     $is_liked = (bool) Model_AlbumImageLike::change_registered_status4unique_key(array('album_image_id' => $album_image_id, 'member_id' => $member_id));
     $album_image = self::$album_image;
     $album_image_like = \Util_Orm::get_last_row('\\Album\\Model_AlbumImageLike', array('album_image_id' => $album_image_id));
     // 件数
     $like_count = \Util_Orm::get_count_all('\\Album\\Model_AlbumImageLike', array('album_image_id' => $album_image_id));
     $like_count_after = $is_liked ? self::$album_image_like_count + 1 : self::$album_image_like_count - 1;
     $this->assertEquals($like_count_after, $like_count);
     if (!$is_liked) {
         $this->assertNull($album_image_like);
     }
     // 値
     $this->assertEquals($like_count, $album_image->like_count);
     $this->assertEquals($album_image_before->sort_datetime, $album_image->sort_datetime);
 }
コード例 #4
0
 public function test_delete()
 {
     $album_image_id = self::$album_image->id;
     $this->save_comment(1, 'Test comment1.');
     $this->save_comment(1, 'Test comment2.');
     $album_image_comment = $this->save_comment(1, 'Test comment3.');
     // set before data.
     $album_image_before = self::get_album_image();
     $album_image_comment_count_before = self::get_album_image_comment_count();
     // album_image_comment delete
     \Util_Develop::sleep();
     $album_image_comment->delete();
     $album_image = self::get_album_image();
     // 件数
     $comment_count = self::get_album_image_comment_count();
     $this->assertEquals($album_image_comment_count_before - 1, $comment_count);
     // 値
     $this->assertEquals($comment_count, $album_image->comment_count);
     $this->assertEquals($album_image_before->sort_datetime, $album_image->sort_datetime);
 }
コード例 #5
0
 /**
  * @dataProvider update_like_provider
  */
 public function test_update_like($member_id)
 {
     // timeline_like save
     \Util_Develop::sleep();
     $is_liked = self::execute_like(self::$timeline_comment->id, $member_id);
     self::$timeline_comment = Model_TimelineComment::find(self::$timeline_comment->id);
     $timeline_comment_like = \Util_Orm::get_last_row('\\Timeline\\Model_TimelineCommentLike', array('timeline_comment_id' => self::$timeline_comment->id));
     // 件数
     $like_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCommentLike', array('timeline_comment_id' => self::$timeline_comment->id));
     $like_count_expect = $is_liked ? self::$like_count + 1 : self::$like_count - 1;
     $this->assertEquals($like_count_expect, $like_count);
     // 値
     $this->assertEquals($like_count, self::$timeline_comment->like_count);
     if (!$is_liked) {
         $this->assertNull($timeline_comment_like);
     }
     // timeline view cache check
     if (self::$is_check_view_cache) {
         $this->assertEquals(self::$view_cache_before, \Timeline\Site_Util::get_view_cache(self::$timeline->id));
     }
 }
コード例 #6
0
ファイル: notecomment.php プロジェクト: uzura8/flockbird
 public function test_delete()
 {
     $note_id = self::$note_id;
     $this->save_comment(1, 'Test comment1.');
     $this->save_comment(1, 'Test comment2.');
     $note_comment = $this->save_comment(1, 'Test comment3.');
     // set before data.
     $note_before = \DB::select()->from('note')->where('id', $note_id)->execute()->current();
     self::$note_comment_count = \Util_Orm::get_count_all('\\Note\\Model_NoteComment', array('note_id' => self::$note_id));
     // note_comment delete
     \Util_Develop::sleep();
     $note_comment->delete();
     $note = \DB::select()->from('note')->where('id', $note_id)->execute()->current();
     // 件数
     $comment_count = \Util_Orm::get_count_all('\\Note\\Model_NoteComment', array('note_id' => $note_id));
     $this->assertEquals(self::$note_comment_count - 1, $comment_count);
     // 値
     $this->assertEquals($comment_count, $note['comment_count']);
     $this->assertEquals($note_before['sort_datetime'], $note['sort_datetime']);
     // timeline 関連
     if (is_enabled('timeline')) {
         $timeline_id = self::$timeline_id;
         $timeline = \DB::select()->from('timeline')->where('id', $timeline_id)->execute()->current();
         // 値
         $this->assertEquals($comment_count, $timeline['comment_count']);
         $this->assertEquals($note_before['sort_datetime'], $timeline['sort_datetime']);
         // timeline_caches
         $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', $timeline_id)->execute();
         $this->assertCount(2, $timeline_caches);
         foreach ($timeline_caches as $timeline_cache) {
             $this->assertEquals($comment_count, $timeline_cache['comment_count']);
         }
         // timeline view cache check
         if (self::$is_check_view_cache) {
             $timeline_view_cache = \Cache::get(\Timeline\Site_Util::get_cache_key($timeline_id), \Config::get('timeline.articles.cache.expir'));
             $this->assertEquals(self::$view_cache_before, $timeline_view_cache);
         }
     }
 }
コード例 #7
0
ファイル: albumimage.php プロジェクト: uzura8/flockbird
 /**
  * @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));
         }
     }
 }
コード例 #8
0
ファイル: timelinecomment.php プロジェクト: uzura8/flockbird
 public function test_delete()
 {
     $timeline_id = self::$timeline_id;
     self::save_comment(self::$member_id, 'Test comment1.');
     self::save_comment(self::$member_id, 'Test comment2.');
     $timeline_comment = self::save_comment(self::$member_id, 'Test comment3.');
     // timeline_comment delete
     \Util_Develop::sleep();
     $timeline_comment->delete();
     $timeline = Model_Timeline::find($timeline_id);
     // 件数
     $comment_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineComment', array('timeline_id' => $timeline_id));
     $this->assertEquals(self::$timeline_comment_count + 3 - 1, $comment_count);
     // 値
     $this->assertEquals($comment_count, $timeline->comment_count);
     $this->assertEquals(self::$timeline_before->sort_datetime, $timeline->sort_datetime);
     $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', $timeline_id)->execute();
     foreach ($timeline_caches as $timeline_cache) {
         $this->assertEquals($comment_count, $timeline_cache['comment_count']);
     }
     // timeline view cache check
     if (self::$is_check_view_cache) {
         $this->assertEquals(self::$view_cache_before, \Timeline\Site_Util::get_view_cache($timeline->id));
     }
 }