Пример #1
0
 /**
  * @dataProvider update_like_provider
  */
 public function test_update_like($member_id)
 {
     // timeline_like save
     $is_liked = (bool) Model_TimelineLike::change_registered_status4unique_key(array('timeline_id' => self::$timeline->id, 'member_id' => $member_id));
     $timeline = \DB::select()->from('timeline')->where('id', self::$timeline->id)->execute()->current();
     $timeline_like = \Util_Orm::get_last_row('\\Timeline\\Model_TimelineLike', array('timeline_id' => self::$timeline->id));
     // 件数
     $like_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineLike', array('timeline_id' => self::$timeline->id));
     $like_count_after = $is_liked ? self::$timeline_like_count + 1 : self::$timeline_like_count - 1;
     $this->assertEquals($like_count_after, $like_count);
     // 値
     $this->assertEquals($like_count, $timeline['like_count']);
     if ($is_liked) {
         $this->assertEquals(self::$timeline_before->sort_datetime, $timeline['sort_datetime']);
     } else {
         $this->assertNull($timeline_like);
     }
     $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', self::$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(self::$timeline->id, $timeline_cache->timeline_id);
     // 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));
     }
 }
Пример #2
0
 /**
  * @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
 /**
  * @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
 private function set_count()
 {
     self::$album_count = \Util_Orm::get_count_all('\\Album\\Model_Album');
     if (is_enabled('timeline')) {
         self::$timeline_count = \Util_Orm::get_count_all('\\Timeline\\Model_Timeline');
         self::$timeline_cache_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache');
     }
 }
Пример #5
0
 public function test_delete_parent()
 {
     $note_comment_id = self::$note_comment_id;
     $note_comment = Model_NoteComment::find($note_comment_id);
     if (!\Util_Orm::get_count_all('\\Note\\Model_NoteCommentLike', array('note_comment_id' => $note_comment_id))) {
         self::execute_like($note_comment_id, 6);
         self::execute_like($note_comment_id, 7);
     }
     $note_comment->delete();
     $like_count = \Util_Orm::get_count_all('\\Note\\Model_NoteCommentLike', array('note_comment_id' => $note_comment_id));
     $this->assertEquals(0, $like_count);
 }
Пример #6
0
 public function test_delete_parent()
 {
     if (!\Util_Orm::get_count_all('\\Timeline\\Model_TimelineCommentLike', array('timeline_comment_id' => self::$timeline_comment->id))) {
         self::execute_like(self::$timeline_comment->id, 6);
         self::execute_like(self::$timeline_comment->id, 7);
     }
     self::$timeline_comment->delete();
     $like_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCommentLike', array('timeline_comment_id' => self::$timeline_comment->id));
     $this->assertEquals(0, $like_count);
 }
Пример #7
0
 public function test_delete_parent()
 {
     $album_image_comment_id = self::$album_image_comment->id;
     $album_image_comment = Model_AlbumImageComment::find($album_image_comment_id);
     if (!\Util_Orm::get_count_all('\\Album\\Model_AlbumImageCommentLike', array('album_image_comment_id' => $album_image_comment_id))) {
         self::execute_like($album_image_comment_id, 6);
         self::execute_like($album_image_comment_id, 7);
     }
     $album_image_comment->delete();
     $like_count = \Util_Orm::get_count_all('\\Album\\Model_AlbumImageCommentLike', array('album_image_comment_id' => $album_image_comment_id));
     $this->assertEquals(0, $like_count);
 }
Пример #8
0
 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);
         }
     }
 }
Пример #9
0
 private static function set_timeline_count()
 {
     if (is_enabled('timeline')) {
         self::$timeline_count = \Util_Orm::get_count_all('\\Timeline\\Model_Timeline');
         self::$timeline_cache_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache');
     }
 }
Пример #10
0
 private static function get_album_image_comment_count()
 {
     return \Util_Orm::get_count_all('\\Album\\Model_AlbumImageComment', array('album_image_id' => self::$album_image->id));
 }
Пример #11
0
 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));
     }
 }