protected function setUp() { self::$note_comment_count = \Util_Orm::get_count_all('\\Note\\Model_NoteComment', array('note_id' => self::$note_id)); if (is_enabled('timeline')) { $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('note', self::$note_id, \Config::get('timeline.types.note')); $timeline = array_shift($timelines); self::$timeline_id = $timeline->id; } // timeline view cache 作成 if (self::$is_check_view_cache) { self::$view_cache_before = \Timeline\Site_Util::make_view_cache4foreign_table_and_foreign_id('note', $album->id, \Config::get('timeline.types.note')); } }
public static function get_timelines4foreign_table_and_id($foreign_table, $foreign_id) { if ($foreign_table == 'timeline') { if (!($timeline = \Timeline\Model_Timeline::find($foreign_id))) { return false; } return array($timeline->id => $timeline); } if (!in_array($foreign_table, \Timeline\Site_Util::get_accept_timeline_foreign_tables())) { return false; } return \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids($foreign_table, $foreign_id); }
protected function setUp() { self::$note_like_count = \Util_Orm::get_count_all('\\Note\\Model_NoteLike', array('note_id' => self::$note_id)); self::$is_check_view_cache = is_enabled('timeline') && \Config::get('timeline.articles.cache.is_use'); if (is_enabled('timeline')) { $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('note', self::$note_id, \Config::get('timeline.types.note')); $timeline = array_shift($timelines); self::$timeline_id = $timeline->id; self::$timeline_before = $timeline; } // timeline view cache 作成 if (self::$is_check_view_cache) { \Timeline\Site_Util::get_article_main_view(self::$timeline_id); self::$timeline_view_cache_before = \Cache::get(\Timeline\Site_Util::get_cache_key(self::$timeline_id), \Config::get('timeline.articles.cache.expir')); } }
public static function make_view_cache4foreign_table_and_foreign_id($foreign_table, $foreign_id, $type = null) { $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids($foreign_table, $foreign_id, $type); $timeline = array_shift($timelines); Site_Util::get_article_main_view($timeline->id); return \Cache::get(\Timeline\Site_Util::get_cache_key($timeline->id), \Config::get('timeline.articles.cache.expir')); }
public function test_delete_with_relations() { if (!($album = $this->get_album())) { \Util_Develop::output_test_info(__FILE__, __LINE__); $this->markTestSkipped(); } $album_id = $album->id; $member_id = $album->member_id; $album_filesize_total = self::get_album_filesize_total($album_id); $member_filesize_before = self::get_member_filesize_total($member_id); $album->delete(); // 件数 // album $this->assertEquals(self::$album_count - 1, \Util_Orm::get_count_all('\\Album\\Model_Album')); // album_image $album_images = Model_AlbumImage::get4album_id($album_id); $this->assertEmpty($album_images); // filesize $this->assertEquals($member_filesize_before - $album_filesize_total, self::get_member_filesize_total($member_id)); // timeline if (is_enabled('timeline')) { $this->assertEquals(self::$timeline_count - 1, \Util_Orm::get_count_all('\\Timeline\\Model_Timeline')); $this->assertEquals(self::$timeline_cache_count - 2, \Util_Orm::get_count_all('\\Timeline\\Model_TimelineCache')); $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('album', $album_id, \Config::get('timeline.types.album')); $this->assertEmpty($timelines); } }
public static function delete_note_view_cache4album_image_id($album_image_id) { if (!($note_id = \Note\Model_NoteAlbumImage::get_note_id4album_image_id($album_image_id))) { return; } if (!($timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('note', $note_id))) { return; } $timeline = array_shift($timelines); \Timeline\Site_Util::delete_cache($timeline->id, $timeline->type); }
/** * @dataProvider update_public_flag_with_relations_provider */ public function test_update_public_flag_with_relations($public_flag) { $note = $this->get_last_row(); $before = array('public_flag' => $note->public_flag, 'updated_at' => $note->updated_at, 'sort_datetime' => $note->sort_datetime); $note->update_public_flag_with_relations($public_flag); // 件数 $this->assertEquals(self::$note_count, \Util_Orm::get_count_all('\\Note\\Model_Note')); // 値 $this->assertEquals($public_flag, $note->public_flag); // date // 変更なし if ($note->public_flag == $before['public_flag']) { $this->assertEquals($before['updated_at'], $note->updated_at); $this->assertEquals($before['sort_datetime'], $note->sort_datetime); } else { $this->assertTrue(\Util_Date::check_is_future($note->updated_at, $note->created_at)); $this->assertEquals($note->updated_at, $note->sort_datetime); } // timeline if (is_enabled('timeline')) { $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('note', $note->id, \Config::get('timeline.types.note')); if ($note->is_published) { $this->assertCount(1, $timelines); $timeline = array_shift($timelines); $this->assertEquals($note->public_flag, $timeline->public_flag); $this->assertEquals($note->sort_datetime, $timeline->sort_datetime); } else { $this->assertCount(0, $timelines); } } }
/** * @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)); } } }