Example #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));
     }
 }
Example #2
0
 private function main(\Orm\Model $obj)
 {
     if (!$this->_relations) {
         return;
     }
     foreach ($this->_relations as $props) {
         if (!empty($props['check_changed'])) {
             $check_properties = isset($props['check_changed']['check_properties']) ? $props['check_changed']['check_properties'] : array();
             $ignore_properties = isset($props['check_changed']['ignore_properties']) ? $props['check_changed']['ignore_properties'] : array();
             if (!\Util_Orm::check_is_updated($obj, $check_properties, $ignore_properties)) {
                 continue;
             }
         }
         $this->_model_to = $props['model_to'];
         $this->_conditions = $props['conditions'];
         $this->_execute_func = $props['execute_func'];
         if (!empty($props['check_changed'])) {
             $check_properties = isset($props['check_changed']['check_properties']) ? $props['check_changed']['check_properties'] : array();
             $ignore_properties = isset($props['check_changed']['ignore_properties']) ? $props['check_changed']['ignore_properties'] : array();
             if (!\Util_Orm::check_is_updated($obj, $check_properties, $ignore_properties)) {
                 continue;
             }
         }
         $this->execute($obj);
     }
 }
Example #3
0
 public static function _init()
 {
     static::$_properties['member_id'] = Util_Orm::get_relational_numeric_key_prop();
     static::$_properties['email'] = Model_MemberAuth::property('email');
     static::$_properties['token'] = Model_MemberPre::property('token');
     static::$_properties['token']['form']['type'] = false;
 }
Example #4
0
 public static function _init()
 {
     $format_options = conf('form.formats.options', 'news');
     static::$_properties['format']['form']['options'] = $format_options;
     static::$_properties['format']['validation']['in_array'][] = array_keys($format_options);
     if (\Config::get('news.category.isEnabled')) {
         static::$_properties['news_category_id']['label'] = term('news.category.simple');
         $news_category_id_options = \Util_Orm::conv_cols2assoc(Model_NewsCategory::get_all(array('sort_order' => 'asc')), 'id', 'label');
         static::$_properties['news_category_id']['form']['options'] = $news_category_id_options;
         static::$_properties['news_category_id']['validation']['in_array'][] = array_keys($news_category_id_options);
     } else {
         static::$_properties['news_category_id']['form']['type'] = false;
     }
     //if (!Site_Util::check_editor_enabled('html_editor') || !(conf('image.isEnabled', 'news') && conf('image.isInsertBody', 'news')))
     //{
     //	static::$_properties['body']['validation'][] = 'required';
     //}
     if (conf('form.isSecure.isEnabled', 'news')) {
         $is_secure_options = \Site_Form::get_form_options4config('term.isSecure.options');
         static::$_properties['is_secure']['form']['type'] = 'radio';
         static::$_properties['is_secure']['label'] = term('isSecure.label');
         static::$_properties['is_secure']['form']['options'] = $is_secure_options;
         static::$_properties['is_secure']['validation'] = array('required');
         static::$_properties['is_secure']['validation']['in_array'][] = array_keys($is_secure_options);
     }
 }
Example #5
0
 public static function _init()
 {
     static::$_properties['member_id'] = Util_Orm::get_relational_numeric_key_prop();
     static::$_properties['profile_id'] = Util_Orm::get_relational_numeric_key_prop();
     static::$_properties['profile_option_id'] = Util_Orm::get_relational_numeric_key_prop(false);
     static::$_properties['public_flag']['validation']['in_array'][] = Site_Util::get_public_flags();
 }
Example #6
0
 public static function _init()
 {
     static::$_properties['name']['label'] = term('member.name');
     static::$_properties['name']['validation']['min_length'][] = conf('member.name.validation.length.min');
     static::$_properties['name']['validation']['max_length'][] = conf('member.name.validation.length.max');
     if (is_enabled('notice') && conf('mention.isEnabled', 'notice')) {
         static::$_properties['name']['validation']['match_pattern'][] = sprintf('/^(%s)$/u', conf('member.name.validation.match_patterns.register'));
         $method = conf('member.name.validation.blacklist.method');
         if (is_callable($method)) {
             static::$_properties['name']['validation']['not_in_array'][] = call_user_func($method);
         }
     }
     static::$_properties['register_type']['validation']['in_array'][] = Site_Member::get_accept_member_register_types();
     $sex_options = Site_Form::get_form_options4config('term.member.sex.options');
     static::$_properties['sex']['label'] = term('member.sex.label');
     static::$_properties['sex']['form']['options'] = $sex_options;
     static::$_properties['sex']['validation']['in_array'][] = array_keys($sex_options);
     $options_public_flag = Site_Util::get_public_flags();
     static::$_properties['sex_public_flag']['label'] = sprintf('%sの%s', term('member.sex.label'), term('public_flag.label'));
     static::$_properties['sex_public_flag']['form'] = Site_Form::get_public_flag_configs();
     static::$_properties['sex_public_flag']['validation']['in_array'][] = $options_public_flag;
     static::$_properties['birthyear']['label'] = term('member.birthyear');
     $options = Form_Util::get_year_options(conf('member.profile.birthday.year_from'), conf('member.profile.birthday.year_to'));
     static::$_properties['birthyear']['form']['options'] = $options;
     static::$_properties['birthyear']['validation']['in_array'][] = array_keys($options);
     static::$_properties['birthyear_public_flag']['label'] = sprintf('%sの%s', term('member.birthyear'), term('public_flag.label'));
     static::$_properties['birthyear_public_flag']['form'] = Site_Form::get_public_flag_configs();
     static::$_properties['birthyear_public_flag']['validation']['in_array'][] = $options_public_flag;
     static::$_properties['birthday']['label'] = term('member.birthday');
     static::$_properties['birthday_public_flag']['label'] = sprintf('%sの%s', term('member.birthday'), term('public_flag.label'));
     static::$_properties['birthday_public_flag']['form'] = Site_Form::get_public_flag_configs();
     static::$_properties['birthday_public_flag']['validation']['in_array'][] = $options_public_flag;
     static::$_properties['invite_member_id'] = Util_Orm::get_relational_numeric_key_prop(false);
 }
Example #7
0
 public static function _init()
 {
     static::$_properties['member_id'] = Util_Orm::get_relational_numeric_key_prop();
     static::$_properties['email'] = Model_MemberAuth::property('email');
     static::$_properties['token'] = Model_MemberPre::property('token');
     static::$_properties['token']['form']['type'] = false;
     static::$_properties['code']['label'] = term('form.confirm', 'site.code');
     static::$_properties['code']['form']['validation']['exact_length'] = array(conf('member.setting.email.codeLength'));
 }
Example #8
0
 public function before_update(\Orm\Model $obj)
 {
     if (\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         if (!empty($obj->{$this->_property_from})) {
             $obj->{$this->_property} = $obj->{$this->_property_from};
         } else {
             $obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
         }
     }
 }
Example #9
0
 public static function get_news_ids4tags($tags)
 {
     if (!is_array($tags)) {
         $tags = (array) $tags;
     }
     if (!($tag_ids = \Model_Tag::get_ids4names($tags))) {
         return array();
     }
     $objs = self::query()->where('tag_id', 'in', $tag_ids)->get();
     return \Util_Orm::conv_col2array($objs, 'news_id');
 }
Example #10
0
 public static function _init()
 {
     static::$_properties['foreign_table']['validation']['in_array'][] = Site_Util::get_accept_foreign_tables();
     static::$_properties['foreign_id'] = \Util_Orm::get_relational_numeric_key_prop();
     static::$_properties['type']['validation']['in_array'][] = \Config::get('notice.types');
     static::$_properties['parent_table']['validation']['in_array'][] = Site_Util::get_accept_parent_tables();
     static::$_properties['parent_id'] = \Util_Orm::get_relational_numeric_key_prop(false);
     // unread cache を削除
     if (\Config::get('notice.cache.unreadCount.isEnabled')) {
         static::$_observers['MyOrm\\Observer_DeleteUnreadNoticeCountCache'] = array('events' => array('before_delete'));
     }
 }
Example #11
0
 public static function get_mentioned_member_ids4body($body)
 {
     if (!preg_match_all(Site_Util::get_match_pattern2mention(), $body, $matches, PREG_SET_ORDER)) {
         return array();
     }
     $member_names = array();
     foreach ($matches as $match) {
         $member_names[] = $match[2];
     }
     if (!($members = \Model_Member::query()->where('name', 'in', $member_names)->get())) {
         array();
     }
     return \Util_Orm::conv_col2array($members, 'id');
 }
 private function main(\Orm\Model $obj)
 {
     if (!$this->_relations) {
         return;
     }
     if (!\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         return;
     }
     foreach ($this->_relations as $props) {
         $this->_model_to = $props['model_to'];
         $this->_conditions = $props['conditions'];
         $this->_update_properties = $props['update_properties'];
         $this->execute($obj);
     }
 }
Example #13
0
 public static function get_notice_target_member_ids($member_id_to, $member_id_from, $foreign_table, $foreign_id, $type_key)
 {
     $notice_member_ids = \Util_Orm::conv_col2array(\Notice\Model_MemberWatchContent::get4foreign_data($foreign_table, $foreign_id), 'member_id');
     if ($member_id_to && !in_array($member_id_to, $notice_member_ids)) {
         $notice_member_ids[] = $member_id_to;
     }
     $notice_member_ids = \Util_Array::unset_item($member_id_from, $notice_member_ids);
     if ($type_key == 'comment_like') {
         $type_key = 'like';
     }
     if (!in_array($type_key, array('comment', 'like'))) {
         return $notice_member_ids;
     }
     $config_key = \Notice\Form_MemberConfig::get_name($type_key);
     return \Site_Member::get_member_ids4config_value($config_key, 1, $notice_member_ids);
 }
 private function main(\Orm\Model $obj)
 {
     if (!\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         return;
     }
     if (!($datetime = $this->get_datetime_from_relational_model($obj))) {
         if (!$obj->is_new() || !empty($obj->{$this->_property})) {
             return;
         }
         if (!empty($obj->{$this->_property_created_at})) {
             $datetime = $obj->{$this->_property_created_at};
         } else {
             $datetime = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp();
         }
     }
     $obj->{$this->_property} = $datetime;
 }
Example #15
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);
         }
     }
 }
Example #16
0
 public static function delete_album_image_multiple4ids($album_image_ids = array(), $with_delete_timeline = false)
 {
     if (!is_array($album_image_ids)) {
         $album_image_ids = (array) $album_image_ids;
     }
     $delete_target_notice_cache_member_ids = array();
     $delete_target_timeline_ids = array();
     $writable_connection = \MyOrm\Model::connection(true);
     \DBUtil::set_connection($writable_connection);
     \DB::start_transaction();
     foreach ($album_image_ids as $album_image_id) {
         if (is_enabled('notice')) {
             \Notice\Site_NoOrmModel::delete_member_watch_content_multiple4foreign_data('album_image', $album_image_id);
             $notice_ids = \Notice\Site_NoOrmModel::get_notice_ids4foreign_data('album_image', $album_image_id);
             $delete_target_notice_cache_member_ids += \Notice\Site_NoOrmModel::get_notice_status_member_ids4notice_ids($notice_ids);
             \Notice\Site_NoOrmModel::delete_notice_multiple4ids($notice_ids);
         }
         if (is_enabled('timeline') && $with_delete_timeline) {
             $delete_target_timeline_ids += \timeline\site_noormmodel::delete_timeline_multiple4foreign_data('album_image', $album_image_id);
         }
     }
     $file_names = \Util_Orm::conv_col2array(Model_AlbumImage::get4ids($album_image_ids), 'file_name');
     \DB::delete('album_image')->where('id', 'in', $album_image_ids)->execute();
     \DB::commit_transaction();
     \DBUtil::set_connection(null);
     \DB::start_transaction();
     if ($files = \Model_File::get4names($file_names)) {
         foreach ($files as $file) {
             $file->delete();
         }
     }
     \DB::commit_transaction();
     // delete caches
     if ($delete_target_notice_cache_member_ids) {
         foreach ($delete_target_notice_cache_member_ids as $member_id) {
             \Notice\Site_Util::delete_unread_count_cache($member_id);
         }
     }
     if ($delete_target_timeline_ids) {
         foreach ($delete_target_timeline_ids as $timeline_id) {
             \Timeline\Site_Util::delete_cache($timeline_id);
         }
     }
 }
Example #17
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);
 }
 private function get_relational_model($obj, $model_from_info)
 {
     if (!$model_from_info) {
         return false;
     }
     if (is_array($model_from_info)) {
         foreach ($model_from_info as $value_from => $type) {
             if ($type == 'model') {
                 $model_from = $value_from;
                 break;
             } elseif ($type == 'timeline_related_table') {
                 if (empty($obj->{$value_from})) {
                     return false;
                 }
                 $namespace = \Timeline\Site_Util::get_namespace4foreign_table($obj->{$value_from});
                 $model_from = \Util_Orm::get_model_name($obj->{$value_from}, $namespace);
             }
         }
     } else {
         $model_from = $model_from_info;
     }
     return $model_from;
 }
Example #19
0
 public static function _init()
 {
     static::$_properties['member_id'] = Util_Orm::get_relational_numeric_key_prop();
 }
Example #20
0
 public function after_update(\Orm\Model $obj)
 {
     if (\Util_Orm::check_is_updated($obj, $this->_check_properties, $this->_ignore_properties)) {
         \Timeline\Site_Util::delete_cache($obj->id, $obj->type);
     }
 }
Example #21
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');
     }
 }
Example #22
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);
 }
Example #23
0
 public static function get_member_ids4config_value($config_name, $config_value, $target_member_ids = array(), $is_fill_default_value = true)
 {
     if (!is_array($target_member_ids)) {
         $target_member_ids = (array) $target_member_ids;
     }
     $member_configs = Util_Orm::conv_cols2assoc(Model_MemberConfig::get4name_and_member_ids($config_name, $target_member_ids), 'member_id', 'value');
     $return_member_ids = array();
     foreach ($target_member_ids as $member_id) {
         if (isset($member_configs[$member_id])) {
             $value = $member_configs[$member_id];
         } else {
             if (!$is_fill_default_value) {
                 continue;
             }
             $value = self::get_config_default($config_name);
         }
         if ($value != $config_value) {
             continue;
         }
         $return_member_ids[] = $member_id;
     }
     return $return_member_ids;
 }
Example #24
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);
 }
 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);
 }
Example #26
0
 public static function _init()
 {
     static::$_properties['member_id'] = Util_Orm::get_relational_numeric_key_prop();
     static::$_properties['name'] = Model_Member::property('name');
     static::$_properties['email'] = Model_MemberAuth::property('email');
 }
Example #27
0
 public static function get_album_cover_filename($cover_album_image_id = 0, $album_id = 0, $access_from = 'others')
 {
     $public_flag_conds = \Site_Model::get_where_public_flag4access_from($access_from);
     $query = \Util_Orm::add_query_where(self::query(), $public_flag_conds);
     if ($cover_album_image_id) {
         $query->where('id', $cover_album_image_id);
         if ($album_image = $query->get_one()) {
             return $album_image->get_image();
         }
     }
     $query = \Util_Orm::add_query_where(self::query(), $public_flag_conds);
     $query->where('album_id', $album_id);
     $query->order_by('id', 'asc');
     $query->rows_limit(1);
     if (!($album_image = $query->get_one())) {
         return '';
     }
     return $album_image->get_image();
 }
Example #28
0
 private static function set_values_as_assoc()
 {
     $objs = self::query()->get();
     self::$values = Util_Orm::conv_cols2assoc($objs, 'name', 'value');
 }
Example #29
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);
         }
     }
 }
Example #30
0
 public static function check_properties_updated(\Orm\Model $obj, $check_properties)
 {
     if (empty($check_properties)) {
         return false;
     }
     $check_properties = (array) $check_properties;
     foreach ($check_properties as $key => $property) {
         if (is_array($property)) {
             $conditions = $property;
             $property = $key;
             foreach ($conditions as $condition => $value) {
                 if (!$obj->is_changed($property)) {
                     continue;
                 }
                 if ($condition == 'ignore_property') {
                     if ($obj->is_changed($value)) {
                         continue;
                     }
                     return true;
                 }
                 if ($condition == 'ignore_value') {
                     list($before, $after) = \Util_Orm::get_changed_values($obj, $property);
                     if ($value == 'reduced_public_flag_range') {
                         if (Site_Util::check_is_reduced_public_flag_range($before, $after)) {
                             continue;
                         }
                     } elseif ($value == 'reduced_num') {
                         if (preg_match('/`' . $property . '`\\s+\\-\\s+1/', $after)) {
                             continue;
                         }
                         if (is_numeric($before) && is_numeric($after) && $before > $after) {
                             continue;
                         }
                     }
                     return true;
                 }
             }
         } else {
             if ($obj->is_changed($property)) {
                 return true;
             }
         }
     }
     return false;
 }