Exemplo n.º 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));
     }
 }
Exemplo n.º 2
0
 /**
  * @dataProvider save_comment_provider
  */
 public function test_save_comment($member_id, $body)
 {
     $timeline_id = self::$timeline_id;
     // timeline_comment save
     \Util_Develop::sleep();
     $timeline_comment = self::save_comment($member_id, $body);
     $timeline = \DB::select()->from('timeline')->where('id', $timeline_id)->execute()->current();
     // 件数
     $comment_count = \Util_Orm::get_count_all('\\Timeline\\Model_TimelineComment', array('timeline_id' => $timeline_id));
     $this->assertEquals(self::$timeline_comment_count + 1, $comment_count);
     // 値
     $this->assertEquals($comment_count, $timeline['comment_count']);
     $this->assertEquals($timeline_comment->created_at, $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_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 {
             $view_cache = \Cache::get(\Timeline\Site_Util::get_cache_key($timeline_id), \Config::get('timeline.articles.cache.expir'));
         } catch (\CacheNotFoundException $e) {
             $view_cache = null;
         }
         $this->assertEquals(self::$view_cache_before, $view_cache);
     }
 }
Exemplo n.º 3
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);
     }
 }
Exemplo n.º 4
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);
         }
     }
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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));
     }
 }
Exemplo n.º 7
0
 /**
  * @dataProvider save_comment_provider
  */
 public function test_save_comment($member_id, $body)
 {
     // note_comment save
     \Util_Develop::sleep();
     $note_comment = $this->save_comment($member_id, $body);
     $note_id = self::$note_id;
     $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_comment->created_at, $note['sort_datetime']);
     // timeline 関連
     if (is_enabled('timeline')) {
         $timeline_id = self::$timeline_id;
         $timeline = \Timeline\Model_Timeline::find($timeline_id);
         // 値
         $this->assertEquals($comment_count, $timeline->comment_count);
         $this->assertEquals($note_comment->created_at, $timeline->sort_datetime);
         $this->assertEquals($note['sort_datetime'], $timeline->sort_datetime);
         $timeline_caches = \DB::select()->from('timeline_cache')->where('timeline_id', $timeline_id)->execute();
         // timeline_caches
         $this->assertCount(2, $timeline_caches);
         foreach ($timeline_caches as $timeline_cache) {
             $this->assertEquals($comment_count, $timeline_cache['comment_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) {
             $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);
         }
     }
 }
Exemplo n.º 8
0
 private function get_last_row()
 {
     return \Util_Orm::get_last_row('\\Note\\Model_Note');
 }