コード例 #1
0
ファイル: album.php プロジェクト: uzura8/flockbird
 /**
  * @dataProvider update_provider
  */
 public function test_update($self_member_id, $values, $album_image_public_flag_expected, $timeline_public_flag_expected)
 {
     $album = $this->get_album();
     $before = array('name' => $album->name, 'body' => $album->body, 'public_flag' => $album->public_flag);
     // 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'));
     }
     // album update
     list($album, $moved_files, $is_changed) = Model_Album::save_with_relations($values, $self_member_id, $album);
     self::$album = $album;
     // 返り値の確認
     $this->assertNotEmpty($album);
     // 件数(増えていないことを確認)
     $this->assertEquals(self::$album_count, \Util_Orm::get_count_all('\\Album\\Model_Album'));
     // album_image の値を変更した場合の public_flag の確認
     $album_images = Model_AlbumImage::get4album_id($album->id);
     $album_image = array_shift($album_images);
     if (!empty($values['is_update_children_public_flag'])) {
         $this->assertEquals($album_image_public_flag_expected, $album_image->public_flag);
     }
     // 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', $album->id, \Config::get('timeline.types.album'));
         $this->assertCount(1, $timelines);
         $timeline = array_shift($timelines);
         $this->assertEquals($album->member_id, $timeline->member_id);
         $this->assertEquals($timeline_public_flag_expected, $timeline->public_flag);
         $this->assertContains($timeline->created_at, \Util_Date::get_datetime_list($album->created_at));
         if ($is_changed) {
             if (self::check_sort_datetime_change(self::$album, $before)) {
                 $this->assertEquals($album->updated_at, $timeline->sort_datetime);
             }
             $this->assertContains($timeline->updated_at, \Util_Date::get_datetime_list($album->updated_at));
         }
         // timeline view cache check
         if (self::$is_check_timeline_view_cache) {
             $this->assertEmpty(\Timeline\Site_Util::get_view_cache($timeline->id));
         }
     }
 }
コード例 #2
0
ファイル: albumimage.php プロジェクト: uzura8/flockbird
 /**
  * @dataProvider insert_provider
  */
 public function test_insert($public_flag, $timeline_public_flag_expected)
 {
     // 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'));
     }
     // insert
     self::$upload_file_path = self::setup_upload_file();
     list($album_image, $file) = Model_AlbumImage::save_with_relations(self::$album->id, self::$member, $public_flag, self::$upload_file_path, 'album_image');
     self::$add_count++;
     // 返り値の確認
     $this->assertNotEmpty($album_image);
     $this->assertNotEmpty($file);
     // 件数
     $this->assertEquals(self::$total_count + 1, \Util_Orm::get_count_all('\\Album\\Model_AlbumImage'));
     // 公開範囲
     $this->assertEquals($public_flag, $album_image->public_flag);
     // 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
         $timelines = \Timeline\Model_Timeline::get4foreign_table_and_foreign_ids('album', self::$album->id, \Config::get('timeline.types.album_image'));
         $this->assertCount(1, $timelines);
         $timeline = array_shift($timelines);
         // timeline_child_data
         $timeline_child_datas = \Timeline\Model_TimelineChildData::get4timeline_id($timeline->id);
         $this->assertCount(self::$add_count, $timeline_child_datas);
         $timeline_child_data = \Util_Array::get_last($timeline_child_datas);
         $this->assertEquals('album_image', $timeline_child_data->foreign_table);
         $this->assertEquals($album_image->id, $timeline_child_data->foreign_id);
         $this->assertEquals($timeline_public_flag_expected, $timeline->public_flag);
         $this->assertContains($timeline->sort_datetime, \Util_Date::get_datetime_list($album_image->created_at));
         $this->assertTrue(\Util_Date::check_is_future($timeline->sort_datetime, self::$album->created_at));
         // timeline view cache check
         if (self::$is_check_timeline_view_cache) {
             $this->assertEmpty(\Timeline\Site_Util::get_view_cache($timeline->id));
         }
     }
 }