diff --git a/app/Http/Controllers/Api/Annotations/Filters/AnnotationUserController.php b/app/Http/Controllers/Api/Annotations/Filters/AnnotationUserController.php index c9351fa88..19af1e5ff 100644 --- a/app/Http/Controllers/Api/Annotations/Filters/AnnotationUserController.php +++ b/app/Http/Controllers/Api/Annotations/Filters/AnnotationUserController.php @@ -55,12 +55,12 @@ public function index(Request $request, $tid, $uid) $labelsRelation = $model->labels(); return $query - ->join($labelsRelation->getRelated()->getTable(), $labelsRelation->getQualifiedParentKeyName(), '=', $labelsRelation->getQualifiedForeignKeyName()) - ->where($labelsRelation->getRelated()->user()->getQualifiedForeignKeyName(), $uid) - ->join($fileRelation->getRelated()->getTable(), $fileRelation->getQualifiedForeignKeyName(), '=', $ownerKeyName) - ->where($fileRelation->getRelated()->volume()->getQualifiedForeignKeyName(), $tid) - ->select($ownerKeyName) - ->distinct() - ->pluck($ownerKeyName); + ->join($labelsRelation->getRelated()->getTable(), $labelsRelation->getQualifiedParentKeyName(), '=', $labelsRelation->getQualifiedForeignKeyName()) + ->where($labelsRelation->getRelated()->user()->getQualifiedForeignKeyName(), $uid) + ->join($fileRelation->getRelated()->getTable(), $fileRelation->getQualifiedForeignKeyName(), '=', $ownerKeyName) + ->where($fileRelation->getRelated()->volume()->getQualifiedForeignKeyName(), $tid) + ->select($ownerKeyName) + ->distinct() + ->pluck($ownerKeyName); } } diff --git a/app/Http/Controllers/Api/Volumes/Filters/AnnotationLabelController.php b/app/Http/Controllers/Api/Volumes/Filters/AnnotationLabelController.php index dc5d26e62..080258eda 100644 --- a/app/Http/Controllers/Api/Volumes/Filters/AnnotationLabelController.php +++ b/app/Http/Controllers/Api/Volumes/Filters/AnnotationLabelController.php @@ -54,12 +54,12 @@ public function index(Request $request, $tid, $lid) $labelsRelation = $model->labels(); return $query - ->join($labelsRelation->getRelated()->getTable(), $labelsRelation->getQualifiedParentKeyName(), '=', $labelsRelation->getQualifiedForeignKeyName()) - ->where($labelsRelation->getRelated()->label()->getQualifiedForeignKeyName(), $lid) - ->join($fileRelation->getRelated()->getTable(), $fileRelation->getQualifiedForeignKeyName(), '=', $ownerKeyName) - ->where($fileRelation->getRelated()->volume()->getQualifiedForeignKeyName(), $tid) - ->select($ownerKeyName) - ->distinct() - ->pluck($ownerKeyName); + ->join($labelsRelation->getRelated()->getTable(), $labelsRelation->getQualifiedParentKeyName(), '=', $labelsRelation->getQualifiedForeignKeyName()) + ->where($labelsRelation->getRelated()->label()->getQualifiedForeignKeyName(), $lid) + ->join($fileRelation->getRelated()->getTable(), $fileRelation->getQualifiedForeignKeyName(), '=', $ownerKeyName) + ->where($fileRelation->getRelated()->volume()->getQualifiedForeignKeyName(), $tid) + ->select($ownerKeyName) + ->distinct() + ->pluck($ownerKeyName); } } diff --git a/app/Jobs/CloneImagesOrVideos.php b/app/Jobs/CloneImagesOrVideos.php index 5184270f2..b2ef17123 100644 --- a/app/Jobs/CloneImagesOrVideos.php +++ b/app/Jobs/CloneImagesOrVideos.php @@ -229,8 +229,8 @@ private function copyImageAnnotation($volume, $copy, $selectedFileIds, $selected '=', 'image_annotations.id' ) - ->when(!empty($selectedLabelIds), fn ($query) => $query->whereIn('image_annotation_labels.label_id', $selectedLabelIds)) - ->whereIn('image_annotations.image_id', $selectedFileIds); + ->when(!empty($selectedLabelIds), fn ($query) => $query->whereIn('image_annotation_labels.label_id', $selectedLabelIds)) + ->whereIn('image_annotations.image_id', $selectedFileIds); // use unique ids, because an annotation with multiple labels would be duplicated @@ -384,9 +384,9 @@ private function copyVideoAnnotation($volume, $copy, $selectedFileIds, $selected '=', 'video_annotations.id' ) - ->when(!empty($selectedLabelIds), fn ($query) => $query->whereIn('video_annotation_labels.label_id', $selectedLabelIds)) - ->whereIn('video_annotations.video_id', $selectedFileIds) - ->distinct(); + ->when(!empty($selectedLabelIds), fn ($query) => $query->whereIn('video_annotation_labels.label_id', $selectedLabelIds)) + ->whereIn('video_annotations.video_id', $selectedFileIds) + ->distinct(); // use unique ids, because an annotation with multiple labels would be duplicated $usedAnnotationIds = $annotationJoinLabel @@ -480,7 +480,8 @@ private function copyVideoLabels($volume, $copy, $selectedFileIds, $selectedLabe fn ($q) => $q->with('labels') ) ->orderBy('id') - ->get()->map(function ($oldVideo) use ($newVideoIds) { + ->get() + ->map(function ($oldVideo) use ($newVideoIds) { $newVideoId = $newVideoIds->shift(); $oldVideo->labels->map(function ($oldLabel) use ($newVideoId) { $origin = $oldLabel->getRawOriginal(); diff --git a/app/Jobs/ProcessNewImage.php b/app/Jobs/ProcessNewImage.php index d893248a2..65f953733 100644 --- a/app/Jobs/ProcessNewImage.php +++ b/app/Jobs/ProcessNewImage.php @@ -126,9 +126,7 @@ protected function makeThumbnail(Image $image, $path) { $prefix = fragment_uuid_path($image->uuid); $format = config('thumbnails.format'); - $buffer = VipsImage::thumbnail($path, $this->width, [ - 'height' => $this->height, - ]) + $buffer = VipsImage::thumbnail($path, $this->width, ['height' => $this->height]) // Strip EXIF information to not auto rotate thumbnails because // the orientation of AUV captured images is not reliable. ->writeToBuffer(".{$format}", [ @@ -137,7 +135,7 @@ protected function makeThumbnail(Image $image, $path) ]); Storage::disk(config('thumbnails.storage_disk')) - ->put("{$prefix}.{$format}", $buffer); + ->put("{$prefix}.{$format}", $buffer); } /** diff --git a/app/Project.php b/app/Project.php index 97322dafd..4098402ff 100644 --- a/app/Project.php +++ b/app/Project.php @@ -328,14 +328,10 @@ public function getThumbnailUrlAttribute() public function hasGeoInfo() { return Cache::remember("project-{$this->id}-has-geo-info", 3600, function () { - return Image::whereIn('volume_id', function ($query) { - return $query->select('volume_id') - ->from('project_volume') - ->where('project_id', $this->id); - }) - ->whereNotNull('lng') - ->whereNotNull('lat') - ->exists(); + return Image::whereIn('volume_id', fn ($q) => $q->select('volume_id')->from('project_volume')->where('project_id', $this->id)) + ->whereNotNull('lng') + ->whereNotNull('lat') + ->exists(); }); } diff --git a/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php b/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php index ee5ffaa16..d8b66123b 100644 --- a/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php +++ b/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php @@ -148,9 +148,10 @@ public function testJoinRedirect() $pid = $this->project()->id; $this->beUser(); - $this->post("/api/v1/project-invitations/{$id}/join", [ - 'token' => $invitation->uuid, - ]) + $this + ->post("/api/v1/project-invitations/{$id}/join", [ + 'token' => $invitation->uuid, + ]) ->assertRedirect("projects/{$pid}"); } diff --git a/tests/php/Http/Controllers/Api/ProjectVolumeControllerTest.php b/tests/php/Http/Controllers/Api/ProjectVolumeControllerTest.php index 4550c6d96..3881dcfd3 100644 --- a/tests/php/Http/Controllers/Api/ProjectVolumeControllerTest.php +++ b/tests/php/Http/Controllers/Api/ProjectVolumeControllerTest.php @@ -334,8 +334,8 @@ public function testStoreFilesExistException() FileCache::shouldReceive('exists') ->andThrow(new Exception('Invalid MIME type.')); - $response = - $this->postJson("/api/v1/projects/{$id}/volumes", [ + $response = $this + ->postJson("/api/v1/projects/{$id}/volumes", [ 'name' => 'my volume no. 1', 'url' => 'test://images', 'media_type' => 'image', diff --git a/tests/php/Http/Controllers/Api/VolumeControllerTest.php b/tests/php/Http/Controllers/Api/VolumeControllerTest.php index 62732ee1d..e3c59b237 100644 --- a/tests/php/Http/Controllers/Api/VolumeControllerTest.php +++ b/tests/php/Http/Controllers/Api/VolumeControllerTest.php @@ -244,8 +244,8 @@ public function testUpdateRedirect() public function testCloneVolume() { - $volume = - $this->volume([ + $volume = $this + ->volume([ 'created_at' => '2022-11-09 14:37:00', 'updated_at' => '2022-11-09 14:37:00', ]) diff --git a/tests/php/Http/Controllers/Api/VolumeFileControllerTest.php b/tests/php/Http/Controllers/Api/VolumeFileControllerTest.php index ecb6ee98c..9a9fb31a7 100644 --- a/tests/php/Http/Controllers/Api/VolumeFileControllerTest.php +++ b/tests/php/Http/Controllers/Api/VolumeFileControllerTest.php @@ -97,7 +97,7 @@ public function testStoreImage() ]) ->assertStatus(422); - $response = + $response = $this->json('POST', "/api/v1/volumes/{$id}/files", [ 'files' => '1.jpg, 2.jpg', ]); @@ -203,7 +203,7 @@ public function testStoreVideo() ]) ->assertStatus(422); - $response = + $response = $this->json('POST', "/api/v1/volumes/{$id}/files", [ 'files' => '1.mp4, 2.mp4', ]); @@ -270,8 +270,8 @@ public function testStoreFilesExistException() FileCache::shouldReceive('exists') ->andThrow(new Exception('Invalid MIME type.')); - $response = - $this->postJson("/api/v1/volumes/{$id}/files", [ + $response = $this + ->postJson("/api/v1/volumes/{$id}/files", [ 'files' => '1.jpg', ]) ->assertStatus(422); diff --git a/tests/php/Jobs/CloneImagesOrVideosTest.php b/tests/php/Jobs/CloneImagesOrVideosTest.php index c61895bf8..8da61a120 100644 --- a/tests/php/Jobs/CloneImagesOrVideosTest.php +++ b/tests/php/Jobs/CloneImagesOrVideosTest.php @@ -29,11 +29,10 @@ class CloneImagesOrVideosTest extends \ApiTestCase public function testCloneImageVolume() { Event::fake(); - $volume = - $this->volume( - ['created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00']) - ->fresh(); // Use fresh() to load even the null fields. + $volume = $this->volume([ + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh(); // Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); @@ -41,16 +40,14 @@ public function testCloneImageVolume() $project = ProjectTest::create(); $project->addVolumeId($copy->id); - $oldImage = - ImageTest::create([ - 'filename' => 'a123.jpg', - 'taken_at' => Carbon::now()->setTimezone('Europe/Lisbon'), - 'volume_id' => $volume->id, - 'lng' => 1.5, - 'lat' => 5.3, - 'tiled' => true, - ]) - ->fresh(); + $oldImage = ImageTest::create([ + 'filename' => 'a123.jpg', + 'taken_at' => Carbon::now()->setTimezone('Europe/Lisbon'), + 'volume_id' => $volume->id, + 'lng' => 1.5, + 'lat' => 5.3, + 'tiled' => true, + ])->fresh(); ImageLabelTest::create(['image_id' => $oldImage->id]); $request = new Request(['project' => $project, 'volume' => $volume]); @@ -77,29 +74,25 @@ public function testCloneImageVolume() public function testCloneVideoVolume() { Event::fake(); - $volume = - VolumeTest::create( - ['created_at' => '2022-01-09 14:37:00', - 'updated_at' => '2022-01-09 14:37:00', - 'media_type_id' => MediaType::videoId(), - ]) - ->fresh(); // Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'created_at' => '2022-01-09 14:37:00', + 'updated_at' => '2022-01-09 14:37:00', + 'media_type_id' => MediaType::videoId(), + ])->fresh(); // Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. $project = ProjectTest::create(); $project->addVolumeId($copy->id); - $oldVideo = - VideoTest::create([ - 'filename' => 'a321123.jpg', - 'taken_at' => [Carbon::now()->setTimezone('Europe/Lisbon')], - 'volume_id' => $volume->id, - 'lng' => 1.5, - 'lat' => 5.3, - 'duration' => 42.42, - ]) - ->fresh(); + $oldVideo = VideoTest::create([ + 'filename' => 'a321123.jpg', + 'taken_at' => [Carbon::now()->setTimezone('Europe/Lisbon')], + 'volume_id' => $volume->id, + 'lng' => 1.5, + 'lat' => 5.3, + 'duration' => 42.42, + ])->fresh(); VideoLabelTest::create(['video_id' => $oldVideo->id]); $request = new Request(['project' => $project, 'volume' => $volume]); @@ -116,29 +109,25 @@ public function testCloneVideoVolume() public function testCloneVolumeImages() { Event::fake(); - $volume = - $this->volume([ - 'media_type_id' => MediaType::imageId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh(); // Use fresh() to load even the null fields. + $volume = $this->volume([ + 'media_type_id' => MediaType::imageId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh(); // Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. $project = ProjectTest::create(); $project->addVolumeId($copy->id); - $oldImage = - ImageTest::create([ - 'filename' => 'j.jpg', - 'taken_at' => Carbon::now()->setTimezone('Europe/Lisbon'), - 'volume_id' => $volume->id, - 'lng' => 1.5, - 'lat' => 5.3, - 'tiled' => true, - ]) - ->fresh(); + $oldImage = ImageTest::create([ + 'filename' => 'j.jpg', + 'taken_at' => Carbon::now()->setTimezone('Europe/Lisbon'), + 'volume_id' => $volume->id, + 'lng' => 1.5, + 'lat' => 5.3, + 'tiled' => true, + ])->fresh(); ImageLabelTest::create(['image_id' => $oldImage->id]); $oldImageLabel = $oldImage->labels()->first(); @@ -177,29 +166,25 @@ public function testCloneVolumeImages() public function testCloneVolumeImagesWithSomeLabels() { - $volume = - VolumeTest::create([ - 'media_type_id' => MediaType::imageId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'media_type_id' => MediaType::imageId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh(); // Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. $project = ProjectTest::create(); $project->addVolumeId($copy->id); - $oldImage = - ImageTest::create([ - 'filename' => 'z.jpg', - 'taken_at' => Carbon::now()->setTimezone('Europe/Lisbon'), - 'volume_id' => $volume->id, - 'lng' => 1.5, - 'lat' => 5.3, - 'tiled' => true, - ]) - ->fresh(); + $oldImage = ImageTest::create([ + 'filename' => 'z.jpg', + 'taken_at' => Carbon::now()->setTimezone('Europe/Lisbon'), + 'volume_id' => $volume->id, + 'lng' => 1.5, + 'lat' => 5.3, + 'tiled' => true, + ])->fresh(); ImageLabelTest::create(['image_id' => $oldImage->id]); $oldImage->volume_id = $volume->id; $oldImage->save(); @@ -207,8 +192,12 @@ public function testCloneVolumeImagesWithSomeLabels() $l2 = ImageLabelTest::create(['image_id' => $oldImage->id]); $l3 = ImageLabelTest::create(['image_id' => $oldImage->id]); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_file_labels' => true, - 'only_file_labels' => [$l2->label_id, $l3->label_id]]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_file_labels' => true, + 'only_file_labels' => [$l2->label_id, $l3->label_id], + ]); with(new CloneImagesOrVideos($request, $copy))->handle(); @@ -224,33 +213,33 @@ public function testCloneVolumeImagesWithSomeLabels() public function testCloneVolumeVideos() { Event::fake(); - $volume = - $this->volume([ - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - 'media_type_id' => MediaType::videoId(), - ]) - ->fresh(); // Use fresh() to load even the null fields. + $volume = $this->volume([ + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + 'media_type_id' => MediaType::videoId(), + ])->fresh(); // Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. $project = ProjectTest::create(); $project->addVolumeId($copy->id); - $oldVideo = - VideoTest::create([ - 'filename' => 'a.jpg', - 'taken_at' => [Carbon::now()->setTimezone('Europe/Lisbon')], - 'volume_id' => $volume->id, - 'lng' => 1.5, - 'lat' => 5.3, - 'duration' => 42.42, - ]) - ->fresh(); + $oldVideo = VideoTest::create([ + 'filename' => 'a.jpg', + 'taken_at' => [Carbon::now()->setTimezone('Europe/Lisbon')], + 'volume_id' => $volume->id, + 'lng' => 1.5, + 'lat' => 5.3, + 'duration' => 42.42, + ])->fresh(); VideoLabelTest::create(['video_id' => $oldVideo->id]); $oldVideoLabel = $oldVideo->labels()->first(); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_file_labels' => true]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_file_labels' => true, + ]); with(new CloneImagesOrVideos($request, $copy))->handle(); Queue::assertPushed(ProcessNewVolumeFiles::class); @@ -284,29 +273,25 @@ public function testCloneVolumeVideos() public function testCloneVolumeVideosWithSomeLabels() { - $volume = - VolumeTest::create([ - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - 'media_type_id' => MediaType::videoId(), - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + 'media_type_id' => MediaType::videoId(), + ])->fresh();// Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. $project = ProjectTest::create(); $project->addVolumeId($copy->id); - $oldVideo = - VideoTest::create([ - 'filename' => 'y.jpg', - 'taken_at' => [Carbon::now()->setTimezone('Europe/Lisbon')], - 'volume_id' => $volume->id, - 'lng' => 1.5, - 'lat' => 5.3, - 'duration' => 42.42, - ]) - ->fresh(); + $oldVideo = VideoTest::create([ + 'filename' => 'y.jpg', + 'taken_at' => [Carbon::now()->setTimezone('Europe/Lisbon')], + 'volume_id' => $volume->id, + 'lng' => 1.5, + 'lat' => 5.3, + 'duration' => 42.42, + ])->fresh(); VideoLabelTest::create(['video_id' => $oldVideo->id]); $oldVideo->volume_id = $volume->id; $oldVideo->save(); @@ -314,8 +299,12 @@ public function testCloneVolumeVideosWithSomeLabels() $l2 = VideoLabelTest::create(['video_id' => $oldVideo->id]); $l3 = VideoLabelTest::create(['video_id' => $oldVideo->id]); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_file_labels' => true, - 'only_file_labels' => [$l2->label_id, $l3->label_id]]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_file_labels' => true, + 'only_file_labels' => [$l2->label_id, $l3->label_id], + ]); with(new CloneImagesOrVideos($request, $copy))->handle(); @@ -331,13 +320,11 @@ public function testCloneVolumeVideosWithSomeLabels() public function testCloneVolumeImageAnnotations() { Event::fake(); - $volume = - $this->volume([ - 'media_type_id' => MediaType::imageId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh(); // Use fresh() to load even the null fields. + $volume = $this ->volume([ + 'media_type_id' => MediaType::imageId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh(); // Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. @@ -346,10 +333,16 @@ public function testCloneVolumeImageAnnotations() $oldImage = ImageTest::create(['volume_id' => $volume->id])->fresh(); $oldAnnotation = ImageAnnotationTest::create(['image_id' => $oldImage->id]); - $oldAnnotationLabel = ImageAnnotationLabelTest::create(['annotation_id' => $oldAnnotation->id]); + $oldAnnotationLabel = ImageAnnotationLabelTest::create([ + 'annotation_id' => $oldAnnotation->id, + ]); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_annotations' => true]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_annotations' => true, + ]); with(new CloneImagesOrVideos($request, $copy))->handle(); Queue::assertPushed(ProcessNewVolumeFiles::class); @@ -383,13 +376,11 @@ public function testCloneVolumeImageAnnotations() public function testCloneVolumeImageAnnotationsWithSomeLabels() { - $volume = - VolumeTest::create([ - 'media_type_id' => MediaType::imageId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'media_type_id' => MediaType::imageId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh();// Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. @@ -404,8 +395,12 @@ public function testCloneVolumeImageAnnotationsWithSomeLabels() $l2 = ImageAnnotationLabelTest::create(['annotation_id' => $oldAnnotation->id]); $l3 = ImageAnnotationLabelTest::create(['annotation_id' => $oldAnnotation->id]); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_annotations' => true, - 'only_annotation_labels' => [$l2->label_id, $l3->label_id]]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_annotations' => true, + 'only_annotation_labels' => [$l2->label_id, $l3->label_id], + ]); with(new CloneImagesOrVideos($request, $copy))->handle(); @@ -421,13 +416,11 @@ public function testCloneVolumeImageAnnotationsWithSomeLabels() public function testCloneVolumeImageWithoutAnnotations() { - $volume = - VolumeTest::create([ - 'media_type_id' => MediaType::imageId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'media_type_id' => MediaType::imageId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh();// Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. @@ -452,13 +445,11 @@ public function testCloneVolumeImageWithoutAnnotations() public function testCloneVolumeVideoAnnotations() { Event::fake(); - $volume = - $this->volume([ - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - 'media_type_id' => MediaType::videoId(), - ]) - ->fresh(); // Use fresh() to load even the null fields. + $volume = $this ->volume([ + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + 'media_type_id' => MediaType::videoId(), + ])->fresh(); // Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. @@ -469,7 +460,11 @@ public function testCloneVolumeVideoAnnotations() $oldAnnotation = VideoAnnotationTest::create(['video_id' => $oldVideo->id]); $oldAnnotationLabel = VideoAnnotationLabelTest::create(['annotation_id' => $oldAnnotation->id]); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_annotations' => true]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_annotations' => true, + ]); with(new CloneImagesOrVideos($request, $copy))->handle(); Queue::assertPushed(ProcessNewVolumeFiles::class); @@ -504,13 +499,11 @@ public function testCloneVolumeVideoAnnotations() public function testCloneVolumeVideoAnnotationsWithSomeLabels() { - $volume = - VolumeTest::create([ - 'media_type_id' => MediaType::videoId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'media_type_id' => MediaType::videoId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh();// Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. @@ -525,8 +518,12 @@ public function testCloneVolumeVideoAnnotationsWithSomeLabels() $l2 = VideoAnnotationLabelTest::create(['annotation_id' => $oldAnnotation->id]); $l3 = VideoAnnotationLabelTest::create(['annotation_id' => $oldAnnotation->id]); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_annotations' => true, - 'only_annotation_labels' => [$l2->label_id, $l3->label_id]]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_annotations' => true, + 'only_annotation_labels' => [$l2->label_id, $l3->label_id], + ]); with(new CloneImagesOrVideos($request, $copy))->handle(); @@ -542,13 +539,11 @@ public function testCloneVolumeVideoAnnotationsWithSomeLabels() public function testCloneVolumeVideoWithoutAnnotations() { - $volume = - VolumeTest::create([ - 'media_type_id' => MediaType::videoId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'media_type_id' => MediaType::videoId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh();// Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); // The target project. @@ -572,13 +567,11 @@ public function testCloneVolumeVideoWithoutAnnotations() public function testCloneVolumeIfDoFiles() { Event::fake(); - $volume = - $this->volume([ - 'media_type_id' => MediaType::imageId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh(); + $volume = $this->volume([ + 'media_type_id' => MediaType::imageId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh(); $copy = $volume->replicate(); $copy->save(); @@ -609,13 +602,11 @@ public function testHandleVolumeImages() // The target project. $project = ProjectTest::create(); - $volume = - VolumeTest::create([ - 'media_type_id' => MediaType::imageId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'media_type_id' => MediaType::imageId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh();// Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); @@ -637,13 +628,11 @@ public function testHandleImageAnnotationPatches() // The target project. $project = ProjectTest::create(); - $volume = - VolumeTest::create([ - 'media_type_id' => MediaType::imageId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'media_type_id' => MediaType::imageId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh();// Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); @@ -651,7 +640,11 @@ public function testHandleImageAnnotationPatches() $oldAnnotation = ImageAnnotationTest::create(['image_id' => $oldImage->id]); ImageAnnotationLabelTest::create(['annotation_id' => $oldAnnotation->id]); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_annotations' => true]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_annotations' => true, + ]); (new CloneImagesOrVideos($request, $copy))->handle(); // One job for the creation of the annotation and one job for GenerateImageAnnotationPatch @@ -668,13 +661,11 @@ public function testHandleVideoAnnotationPatches() // The target project. $project = ProjectTest::create(); - $volume = - VolumeTest::create([ - 'media_type_id' => MediaType::videoId(), - 'created_at' => '2022-11-09 14:37:00', - 'updated_at' => '2022-11-09 14:37:00', - ]) - ->fresh();// Use fresh() to load even the null fields. + $volume = VolumeTest::create([ + 'media_type_id' => MediaType::videoId(), + 'created_at' => '2022-11-09 14:37:00', + 'updated_at' => '2022-11-09 14:37:00', + ])->fresh();// Use fresh() to load even the null fields. $copy = $volume->replicate(); $copy->save(); @@ -682,7 +673,11 @@ public function testHandleVideoAnnotationPatches() $oldAnnotation = VideoAnnotationTest::create(['video_id' => $oldVideo->id]); VideoAnnotationLabelTest::create(['annotation_id' => $oldAnnotation->id]); - $request = new Request(['project' => $project, 'volume' => $volume, 'clone_annotations' => true]); + $request = new Request([ + 'project' => $project, + 'volume' => $volume, + 'clone_annotations' => true, + ]); (new CloneImagesOrVideos($request, $copy))->handle(); // One job for the creation of the annotation and one job for GenerateVideoAnnotationPatch