From ac8859e7663c8028c97cd6b6b4fac2601d7700e8 Mon Sep 17 00:00:00 2001 From: Leane Schlundt Date: Tue, 20 Aug 2024 10:03:29 +0200 Subject: [PATCH] Replace assertEquals by assertSame --- .../Console/Commands/GenerateMissingTest.php | 40 +++++----- tests/Jobs/ApplyLargoSessionTest.php | 52 ++++++------- .../CopyImageAnnotationFeatureVectorTest.php | 10 +-- .../CopyVideoAnnotationFeatureVectorTest.php | 10 +-- .../Jobs/InitializeFeatureVectorChunkTest.php | 58 +++++++-------- tests/Jobs/ProcessAnnotatedImageTest.php | 66 ++++++++--------- tests/Jobs/ProcessAnnotatedVideoTest.php | 74 +++++++++---------- tests/Listeners/AttachLabelListenerTest.php | 4 +- tests/Listeners/ImagesCleanupListenerTest.php | 4 +- tests/Listeners/VideosCleanupListenerTest.php | 4 +- 10 files changed, 161 insertions(+), 161 deletions(-) diff --git a/tests/Console/Commands/GenerateMissingTest.php b/tests/Console/Commands/GenerateMissingTest.php index 80029f74..d55c7260 100644 --- a/tests/Console/Commands/GenerateMissingTest.php +++ b/tests/Console/Commands/GenerateMissingTest.php @@ -24,8 +24,8 @@ public function testHandleImageAnnotations() Bus::fake(); $this->artisan('largo:generate-missing'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a) { - $this->assertEquals($a->image_id, $job->file->id); - $this->assertEquals([$a->id], $job->only); + $this->assertSame($a->image_id, $job->file->id); + $this->assertSame([$a->id], $job->only); return true; }); @@ -55,8 +55,8 @@ public function testHandleVideoAnnotations() Bus::fake(); $this->artisan('largo:generate-missing'); Bus::assertDispatched(ProcessAnnotatedVideo::class, function ($job) use ($a) { - $this->assertEquals($a->video_id, $job->file->id); - $this->assertEquals([$a->id], $job->only); + $this->assertSame($a->video_id, $job->file->id); + $this->assertSame([$a->id], $job->only); return true; }); @@ -130,7 +130,7 @@ public function testHandleVolume() Bus::fake(); $this->artisan("largo:generate-missing --volume={$a1->image->volume_id}"); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a1) { - $this->assertEquals($a1->image_id, $job->file->id); + $this->assertSame($a1->image_id, $job->file->id); return true; }); @@ -175,7 +175,7 @@ public function testHandleQueue() Bus::fake(); $this->artisan('largo:generate-missing --queue=special'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) { - $this->assertEquals('special', $job->queue); + $this->assertSame('special', $job->queue); return true; }); @@ -195,8 +195,8 @@ public function testHandleNewerThan() Bus::fake(); $this->artisan('largo:generate-missing --newer-than=2024-01-23'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a1) { - $this->assertEquals($a1->image_id, $job->file->id); - $this->assertEquals([$a1->id], $job->only); + $this->assertSame($a1->image_id, $job->file->id); + $this->assertSame([$a1->id], $job->only); return true; }); @@ -216,8 +216,8 @@ public function testHandleOlderThan() Bus::fake(); $this->artisan('largo:generate-missing --older-than=2024-01-23'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a2) { - $this->assertEquals($a2->image_id, $job->file->id); - $this->assertEquals([$a2->id], $job->only); + $this->assertSame($a2->image_id, $job->file->id); + $this->assertSame([$a2->id], $job->only); return true; }); @@ -234,8 +234,8 @@ public function testHandleSkipVectors() Bus::fake(); $this->artisan('largo:generate-missing --skip-vectors'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a2) { - $this->assertEquals($a2->image_id, $job->file->id); - $this->assertEquals([$a2->id], $job->only); + $this->assertSame($a2->image_id, $job->file->id); + $this->assertSame([$a2->id], $job->only); $this->assertTrue($job->skipFeatureVectors); $this->assertFalse($job->skipPatches); $this->assertFalse($job->skipSvgs); @@ -259,8 +259,8 @@ public function testHandleSkipPatches() Bus::fake(); $this->artisan('largo:generate-missing --skip-patches'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a2) { - $this->assertEquals($a2->image_id, $job->file->id); - $this->assertEquals([$a2->id], $job->only); + $this->assertSame($a2->image_id, $job->file->id); + $this->assertSame([$a2->id], $job->only); $this->assertFalse($job->skipFeatureVectors); $this->assertTrue($job->skipPatches); $this->assertFalse($job->skipSvgs); @@ -284,8 +284,8 @@ public function testHandleSkipSvgs() Bus::fake(); $this->artisan('largo:generate-missing --skip-svgs'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a2) { - $this->assertEquals($a2->image_id, $job->file->id); - $this->assertEquals([$a2->id], $job->only); + $this->assertSame($a2->image_id, $job->file->id); + $this->assertSame([$a2->id], $job->only); $this->assertFalse($job->skipFeatureVectors); $this->assertFalse($job->skipPatches); $this->assertTrue($job->skipSvgs); @@ -311,8 +311,8 @@ public function testHandleMixedPatchesVectors() Bus::fake(); $this->artisan('largo:generate-missing'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a1, $a2, $a3) { - $this->assertEquals($a1->image_id, $job->file->id); - $this->assertEquals([$a1->id, $a2->id, $a3->id], $job->only); + $this->assertSame($a1->image_id, $job->file->id); + $this->assertSame([$a1->id, $a2->id, $a3->id], $job->only); return true; }); @@ -330,8 +330,8 @@ public function testHandleForceWithVectors() Bus::fake(); $this->artisan('largo:generate-missing --skip-svgs --skip-patches --force'); Bus::assertDispatched(ProcessAnnotatedImage::class, function ($job) use ($a1) { - $this->assertEquals($a1->image_id, $job->file->id); - $this->assertEquals([$a1->id], $job->only); + $this->assertSame($a1->image_id, $job->file->id); + $this->assertSame([$a1->id], $job->only); $this->assertFalse($job->skipFeatureVectors); $this->assertTrue($job->skipPatches); $this->assertTrue($job->skipSvgs); diff --git a/tests/Jobs/ApplyLargoSessionTest.php b/tests/Jobs/ApplyLargoSessionTest.php index a05697f3..9711813a 100644 --- a/tests/Jobs/ApplyLargoSessionTest.php +++ b/tests/Jobs/ApplyLargoSessionTest.php @@ -49,8 +49,8 @@ public function testChangedAlreadyExistsImageAnnotations() $job = new ApplyLargoSession('job_id', $user, $dismissed, $changed, [], [], false); $job->handle(); - $this->assertEquals(1, $a1->labels()->count()); - $this->assertEquals($al2->id, $a1->labels()->first()->id); + $this->assertSame(1, $a1->labels()->count()); + $this->assertSame($al2->id, $a1->labels()->first()->id); } public function testChangedAlreadyExistsVideoAnnotations() @@ -79,8 +79,8 @@ public function testChangedAlreadyExistsVideoAnnotations() $job = new ApplyLargoSession('job_id', $user, [], [], $dismissed, $changed, false); $job->handle(); - $this->assertEquals(1, $a1->labels()->count()); - $this->assertEquals($al2->id, $a1->labels()->first()->id); + $this->assertSame(1, $a1->labels()->count()); + $this->assertSame($al2->id, $a1->labels()->first()->id); } public function testChangedDuplicateImageAnnotations() @@ -104,8 +104,8 @@ public function testChangedDuplicateImageAnnotations() $job = new ApplyLargoSession('job_id', $user, $dismissed, $changed, [], [], false); $job->handle(); - $this->assertEquals(1, $a1->labels()->count()); - $this->assertEquals($l2->id, $a1->labels()->first()->label_id); + $this->assertSame(1, $a1->labels()->count()); + $this->assertSame($l2->id, $a1->labels()->first()->label_id); } public function testChangedDuplicateVideoAnnotations() @@ -129,8 +129,8 @@ public function testChangedDuplicateVideoAnnotations() $job = new ApplyLargoSession('job_id', $user, [], [], $dismissed, $changed, false); $job->handle(); - $this->assertEquals(1, $a1->labels()->count()); - $this->assertEquals($l2->id, $a1->labels()->first()->label_id); + $this->assertSame(1, $a1->labels()->count()); + $this->assertSame($l2->id, $a1->labels()->first()->label_id); } public function testAnnotationMeanwhileDeletedImageAnnotations() @@ -162,7 +162,7 @@ public function testAnnotationMeanwhileDeletedImageAnnotations() $a2->delete(); $job->handle(); - $this->assertEquals($l2->id, $a1->labels()->first()->label_id); + $this->assertSame($l2->id, $a1->labels()->first()->label_id); } public function testAnnotationMeanwhileDeletedVideoAnnotations() @@ -194,7 +194,7 @@ public function testAnnotationMeanwhileDeletedVideoAnnotations() $a2->delete(); $job->handle(); - $this->assertEquals($l2->id, $a1->labels()->first()->label_id); + $this->assertSame($l2->id, $a1->labels()->first()->label_id); } public function testLabelMeanwhileDeletedImageAnnotations() @@ -227,8 +227,8 @@ public function testLabelMeanwhileDeletedImageAnnotations() $l2->delete(); $job->handle(); - $this->assertEquals($l1->id, $a1->labels()->first()->label_id); - $this->assertEquals($l3->id, $a2->labels()->first()->label_id); + $this->assertSame($l1->id, $a1->labels()->first()->label_id); + $this->assertSame($l3->id, $a2->labels()->first()->label_id); } public function testLabelMeanwhileDeletedVideoAnnotations() @@ -261,8 +261,8 @@ public function testLabelMeanwhileDeletedVideoAnnotations() $l2->delete(); $job->handle(); - $this->assertEquals($l1->id, $a1->labels()->first()->label_id); - $this->assertEquals($l3->id, $a2->labels()->first()->label_id); + $this->assertSame($l1->id, $a1->labels()->first()->label_id); + $this->assertSame($l3->id, $a2->labels()->first()->label_id); } public function testDismissImageAnnotations() @@ -339,7 +339,7 @@ public function testChangeOwnImageAnnotations() // al1 was dismissed and then changed, should have a new annotation label $this->assertNull($al1->fresh()); - $this->assertEquals($l1->id, $annotation->labels()->first()->label_id); + $this->assertSame($l1->id, $annotation->labels()->first()->label_id); Queue::assertNotPushed(RemoveImageAnnotationPatches::class); } @@ -357,7 +357,7 @@ public function testChangeOwnVideoAnnotations() // al1 was dismissed and then changed, should have a new annotation label $this->assertNull($al1->fresh()); - $this->assertEquals($l1->id, $annotation->labels()->first()->label_id); + $this->assertSame($l1->id, $annotation->labels()->first()->label_id); Queue::assertNotPushed(RemoveVideoAnnotationPatches::class); } @@ -378,7 +378,7 @@ public function testChangeOtherImageAnnotations() // should get a new additional label. $this->assertNotNull($al1->fresh()); $this->assertNotNull($annotation->fresh()); - $this->assertEquals(2, $annotation->labels()->count()); + $this->assertSame(2, $annotation->labels()->count()); Queue::assertNotPushed(RemoveImageAnnotationPatches::class); } @@ -399,7 +399,7 @@ public function testChangeOtherVideoAnnotations() // should get a new additional label. $this->assertNotNull($al1->fresh()); $this->assertNotNull($annotation->fresh()); - $this->assertEquals(2, $annotation->labels()->count()); + $this->assertSame(2, $annotation->labels()->count()); Queue::assertNotPushed(RemoveVideoAnnotationPatches::class); } @@ -418,7 +418,7 @@ public function testChangeOtherForceImageAnnotations() $this->assertNull($al1->fresh()); $this->assertNotNull($annotation->fresh()); - $this->assertEquals($l1->id, $annotation->labels()->first()->label_id); + $this->assertSame($l1->id, $annotation->labels()->first()->label_id); Queue::assertNotPushed(RemoveImageAnnotationPatches::class); } @@ -437,7 +437,7 @@ public function testChangeOtherForceVideoAnnotations() $this->assertNull($al1->fresh()); $this->assertNotNull($annotation->fresh()); - $this->assertEquals($l1->id, $annotation->labels()->first()->label_id); + $this->assertSame($l1->id, $annotation->labels()->first()->label_id); Queue::assertNotPushed(RemoveVideoAnnotationPatches::class); } @@ -600,8 +600,8 @@ public function testDispatchEventOnSuccess() $job->handle(); Event::assertDispatched(function (LargoSessionSaved $event) use ($user) { - $this->assertEquals($user->id, $event->user->id); - $this->assertEquals('job_id', $event->id); + $this->assertSame($user->id, $event->user->id); + $this->assertSame('job_id', $event->id); return true; }); } @@ -623,8 +623,8 @@ public function testDispatchEventOnError() } Event::assertDispatched(function (LargoSessionFailed $event) use ($user) { - $this->assertEquals($user->id, $event->user->id); - $this->assertEquals('job_id', $event->id); + $this->assertSame($user->id, $event->user->id); + $this->assertSame('job_id', $event->id); return true; }); } @@ -647,7 +647,7 @@ public function testChangeImageAnnotationCopyFeatureVector() $vectors = ImageAnnotationLabelFeatureVector::where('annotation_id', $al1->annotation_id)->get(); $this->assertCount(1, $vectors); $this->assertNotEquals($al1->id, $vectors[0]->id); - $this->assertEquals($l1->id, $vectors[0]->label_id); + $this->assertSame($l1->id, $vectors[0]->label_id); $this->assertEquals($vector1->vector, $vectors[0]->vector); } @@ -669,7 +669,7 @@ public function testChangeVideoAnnotationCopyFeatureVector() $vectors = VideoAnnotationLabelFeatureVector::where('annotation_id', $al1->annotation_id)->get(); $this->assertCount(1, $vectors); $this->assertNotEquals($al1->id, $vectors[0]->id); - $this->assertEquals($l1->id, $vectors[0]->label_id); + $this->assertSame($l1->id, $vectors[0]->label_id); $this->assertEquals($vector1->vector, $vectors[0]->vector); } diff --git a/tests/Jobs/CopyImageAnnotationFeatureVectorTest.php b/tests/Jobs/CopyImageAnnotationFeatureVectorTest.php index cad04dfc..31e49c82 100644 --- a/tests/Jobs/CopyImageAnnotationFeatureVectorTest.php +++ b/tests/Jobs/CopyImageAnnotationFeatureVectorTest.php @@ -21,11 +21,11 @@ public function testHandle() $vectors = ImageAnnotationLabelFeatureVector::where('annotation_id', $vector->annotation_id) ->orderBy('id', 'asc')->get(); $this->assertCount(2, $vectors); - $this->assertEquals($annotationLabel->id, $vectors[1]->id); - $this->assertEquals($annotationLabel->annotation_id, $vectors[1]->annotation_id); - $this->assertEquals($annotationLabel->label_id, $vectors[1]->label_id); - $this->assertEquals($annotationLabel->label->label_tree_id, $vectors[1]->label_tree_id); - $this->assertEquals($vector->volume_id, $vectors[1]->volume_id); + $this->assertSame($annotationLabel->id, $vectors[1]->id); + $this->assertSame($annotationLabel->annotation_id, $vectors[1]->annotation_id); + $this->assertSame($annotationLabel->label_id, $vectors[1]->label_id); + $this->assertSame($annotationLabel->label->label_tree_id, $vectors[1]->label_tree_id); + $this->assertSame($vector->volume_id, $vectors[1]->volume_id); $this->assertEquals($vector->vector, $vectors[1]->vector); } } diff --git a/tests/Jobs/CopyVideoAnnotationFeatureVectorTest.php b/tests/Jobs/CopyVideoAnnotationFeatureVectorTest.php index bc35a521..f3d532d9 100644 --- a/tests/Jobs/CopyVideoAnnotationFeatureVectorTest.php +++ b/tests/Jobs/CopyVideoAnnotationFeatureVectorTest.php @@ -21,11 +21,11 @@ public function testHandle() $vectors = VideoAnnotationLabelFeatureVector::where('annotation_id', $vector->annotation_id) ->orderBy('id', 'asc')->get(); $this->assertCount(2, $vectors); - $this->assertEquals($annotationLabel->id, $vectors[1]->id); - $this->assertEquals($annotationLabel->annotation_id, $vectors[1]->annotation_id); - $this->assertEquals($annotationLabel->label_id, $vectors[1]->label_id); - $this->assertEquals($annotationLabel->label->label_tree_id, $vectors[1]->label_tree_id); - $this->assertEquals($vector->volume_id, $vectors[1]->volume_id); + $this->assertSame($annotationLabel->id, $vectors[1]->id); + $this->assertSame($annotationLabel->annotation_id, $vectors[1]->annotation_id); + $this->assertSame($annotationLabel->label_id, $vectors[1]->label_id); + $this->assertSame($annotationLabel->label->label_tree_id, $vectors[1]->label_tree_id); + $this->assertSame($vector->volume_id, $vectors[1]->volume_id); $this->assertEquals($vector->vector, $vectors[1]->vector); } } diff --git a/tests/Jobs/InitializeFeatureVectorChunkTest.php b/tests/Jobs/InitializeFeatureVectorChunkTest.php index 0f5e3cc4..96142cc9 100644 --- a/tests/Jobs/InitializeFeatureVectorChunkTest.php +++ b/tests/Jobs/InitializeFeatureVectorChunkTest.php @@ -38,12 +38,12 @@ public function testHandleImages() $model = ImageAnnotationLabelFeatureVector::find($al->id); $this->assertNotNull($model); - $this->assertEquals($al->annotation_id, $model->annotation_id); - $this->assertEquals($al->annotation_id, $model->annotation_id); - $this->assertEquals($al->label_id, $model->label_id); - $this->assertEquals($al->label->label_tree_id, $model->label_tree_id); - $this->assertEquals($al->annotation->image->volume_id, $model->volume_id); - $this->assertEquals(range(0, 383), $model->vector->toArray()); + $this->assertSame($al->annotation_id, $model->annotation_id); + $this->assertSame($al->annotation_id, $model->annotation_id); + $this->assertSame($al->label_id, $model->label_id); + $this->assertSame($al->label->label_tree_id, $model->label_tree_id); + $this->assertSame($al->annotation->image->volume_id, $model->volume_id); + $this->assertSame(range(0, 383), $model->vector->toArray()); } public function testHandleVideos() @@ -58,12 +58,12 @@ public function testHandleVideos() $model = VideoAnnotationLabelFeatureVector::find($al->id); $this->assertNotNull($model); - $this->assertEquals($al->annotation_id, $model->annotation_id); - $this->assertEquals($al->annotation_id, $model->annotation_id); - $this->assertEquals($al->label_id, $model->label_id); - $this->assertEquals($al->label->label_tree_id, $model->label_tree_id); - $this->assertEquals($al->annotation->video->volume_id, $model->volume_id); - $this->assertEquals(range(0, 383), $model->vector->toArray()); + $this->assertSame($al->annotation_id, $model->annotation_id); + $this->assertSame($al->annotation_id, $model->annotation_id); + $this->assertSame($al->label_id, $model->label_id); + $this->assertSame($al->label->label_tree_id, $model->label_tree_id); + $this->assertSame($al->annotation->video->volume_id, $model->volume_id); + $this->assertSame(range(0, 383), $model->vector->toArray()); } public function testHandleSkipMissingAnnotations() @@ -91,7 +91,7 @@ public function testHandleSkipExistingVectors() $job->output = $v->annotation_id.',"'.json_encode(range(1, 384)).'"'; $job->handle(); - $this->assertEquals(range(0, 383), $v->fresh()->vector->toArray()); + $this->assertSame(range(0, 383), $v->fresh()->vector->toArray()); } public function testHandleSkipMissingThumbnails() @@ -130,21 +130,21 @@ public function testHandleMultipleLabels() $model = ImageAnnotationLabelFeatureVector::find($al->id); $this->assertNotNull($model); - $this->assertEquals($al->annotation_id, $model->annotation_id); - $this->assertEquals($al->annotation_id, $model->annotation_id); - $this->assertEquals($al->label_id, $model->label_id); - $this->assertEquals($al->label->label_tree_id, $model->label_tree_id); - $this->assertEquals($al->annotation->image->volume_id, $model->volume_id); - $this->assertEquals(range(0, 383), $model->vector->toArray()); + $this->assertSame($al->annotation_id, $model->annotation_id); + $this->assertSame($al->annotation_id, $model->annotation_id); + $this->assertSame($al->label_id, $model->label_id); + $this->assertSame($al->label->label_tree_id, $model->label_tree_id); + $this->assertSame($al->annotation->image->volume_id, $model->volume_id); + $this->assertSame(range(0, 383), $model->vector->toArray()); $model = ImageAnnotationLabelFeatureVector::find($al2->id); $this->assertNotNull($model); - $this->assertEquals($al2->annotation_id, $model->annotation_id); - $this->assertEquals($al2->annotation_id, $model->annotation_id); - $this->assertEquals($al2->label_id, $model->label_id); - $this->assertEquals($al2->label->label_tree_id, $model->label_tree_id); - $this->assertEquals($al2->annotation->image->volume_id, $model->volume_id); - $this->assertEquals(range(0, 383), $model->vector->toArray()); + $this->assertSame($al2->annotation_id, $model->annotation_id); + $this->assertSame($al2->annotation_id, $model->annotation_id); + $this->assertSame($al2->label_id, $model->label_id); + $this->assertSame($al2->label->label_tree_id, $model->label_tree_id); + $this->assertSame($al2->annotation->image->volume_id, $model->volume_id); + $this->assertSame(range(0, 383), $model->vector->toArray()); } public function testHandlePoint() @@ -167,7 +167,7 @@ public function testHandlePoint() $input = $job->input; $path = array_keys($input)[0]; $item = $input[$path]; - $this->assertEquals([23, 0, 158, 135], $item[$a->id]); + $this->assertSame([23, 0, 158, 135], $item[$a->id]); } public function testHandleCircle() @@ -190,7 +190,7 @@ public function testHandleCircle() $input = $job->input; $path = array_keys($input)[0]; $item = $input[$path]; - $this->assertEquals([70, 47, 110, 87], $item[$a->id]); + $this->assertSame([70, 47, 110, 87], $item[$a->id]); } public function testHandlePolygon() @@ -213,7 +213,7 @@ public function testHandlePolygon() $input = $job->input; $path = array_keys($input)[0]; $item = $input[$path]; - $this->assertEquals([70, 47, 110, 87], $item[$a->id]); + $this->assertSame([70, 47, 110, 87], $item[$a->id]); } public function testHandleWholeFrame() @@ -235,7 +235,7 @@ public function testHandleWholeFrame() $input = $job->input; $path = array_keys($input)[0]; $item = $input[$path]; - $this->assertEquals([0, 0, 180, 135], $item[$a->id]); + $this->assertSame([0, 0, 180, 135], $item[$a->id]); } } diff --git a/tests/Jobs/ProcessAnnotatedImageTest.php b/tests/Jobs/ProcessAnnotatedImageTest.php index 4ff2a062..ed0cb1a4 100644 --- a/tests/Jobs/ProcessAnnotatedImageTest.php +++ b/tests/Jobs/ProcessAnnotatedImageTest.php @@ -48,7 +48,7 @@ public function testHandleStorage() $job->handle(); $prefix = fragment_uuid_path($annotation->image->uuid); $content = $disk->get("{$prefix}/{$annotation->id}.jpg"); - $this->assertEquals('abc123', $content); + $this->assertSame('abc123', $content); $disk->assertExists("{$prefix}/{$annotation->id}.svg"); } @@ -71,7 +71,7 @@ public function testHandleStorageConfigurableDisk() $job->handle(); $prefix = fragment_uuid_path($annotation->image->uuid); $content = $disk->get("{$prefix}/{$annotation->id}.jpg"); - $this->assertEquals('abc123', $content); + $this->assertSame('abc123', $content); $disk->assertExists("{$prefix}/{$annotation->id}.svg"); } @@ -98,7 +98,7 @@ public function testHandlePoint() $prefix = fragment_uuid_path($annotation->image->uuid); $content = $disk->get("{$prefix}/{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleCircle() @@ -127,7 +127,7 @@ public function testHandleCircle() $prefix = fragment_uuid_path($annotation->image->uuid); $content = $disk->get("{$prefix}/{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandlePolygon() @@ -153,7 +153,7 @@ public function testHandlePolygon() $prefix = fragment_uuid_path($annotation->image->uuid); $content = $disk->get("{$prefix}/{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleLineString() @@ -179,7 +179,7 @@ public function testHandleLineString() $prefix = fragment_uuid_path($annotation->image->uuid); $content = $disk->get("{$prefix}/{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleRectangle() @@ -207,7 +207,7 @@ public function testHandleRectangle() $prefix = fragment_uuid_path($annotation->image->uuid); $content = $disk->get("{$prefix}/{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleEllipse() @@ -233,7 +233,7 @@ public function testHandleEllipse() $prefix = fragment_uuid_path($annotation->image->uuid); $content = $disk->get("{$prefix}/{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleContainedNegative() @@ -466,15 +466,15 @@ public function testGenerateFeatureVectorNew() $filename = array_keys($input)[0]; $this->assertArrayHasKey($annotation->id, $input[$filename]); $box = $input[$filename][$annotation->id]; - $this->assertEquals([88, 88, 312, 312], $box); + $this->assertSame([88, 88, 312, 312], $box); $vectors = ImageAnnotationLabelFeatureVector::where('annotation_id', $annotation->id)->get(); $this->assertCount(1, $vectors); - $this->assertEquals($annotationLabel->id, $vectors[0]->id); - $this->assertEquals($annotationLabel->label_id, $vectors[0]->label_id); - $this->assertEquals($annotationLabel->label->label_tree_id, $vectors[0]->label_tree_id); - $this->assertEquals($annotation->image->volume_id, $vectors[0]->volume_id); - $this->assertEquals(range(0, 383), $vectors[0]->vector->toArray()); + $this->assertSame($annotationLabel->id, $vectors[0]->id); + $this->assertSame($annotationLabel->label_id, $vectors[0]->label_id); + $this->assertSame($annotationLabel->label->label_tree_id, $vectors[0]->label_tree_id); + $this->assertSame($annotation->image->volume_id, $vectors[0]->volume_id); + $this->assertSame(range(0, 383), $vectors[0]->vector->toArray()); } public function testGenerateFeatureVectorManyLabels() @@ -500,13 +500,13 @@ public function testGenerateFeatureVectorManyLabels() $vectors = ImageAnnotationLabelFeatureVector::where('annotation_id', $annotation->id)->get(); $this->assertCount(2, $vectors); - $this->assertEquals($annotationLabel1->id, $vectors[0]->id); - $this->assertEquals($annotationLabel1->label_id, $vectors[0]->label_id); - $this->assertEquals(range(0, 383), $vectors[0]->vector->toArray()); + $this->assertSame($annotationLabel1->id, $vectors[0]->id); + $this->assertSame($annotationLabel1->label_id, $vectors[0]->label_id); + $this->assertSame(range(0, 383), $vectors[0]->vector->toArray()); - $this->assertEquals($annotationLabel2->id, $vectors[1]->id); - $this->assertEquals($annotationLabel2->label_id, $vectors[1]->label_id); - $this->assertEquals(range(0, 383), $vectors[1]->vector->toArray()); + $this->assertSame($annotationLabel2->id, $vectors[1]->id); + $this->assertSame($annotationLabel2->label_id, $vectors[1]->label_id); + $this->assertSame(range(0, 383), $vectors[1]->vector->toArray()); } public function testGenerateFeatureVectorUpdate() @@ -543,9 +543,9 @@ public function testGenerateFeatureVectorUpdate() $job->handle(); $count = ImageAnnotationLabelFeatureVector::count(); - $this->assertEquals(2, $count); - $this->assertEquals(range(1, 384), $iafv->fresh()->vector->toArray()); - $this->assertEquals(range(1, 384), $iafv2->fresh()->vector->toArray()); + $this->assertSame(2, $count); + $this->assertSame(range(1, 384), $iafv->fresh()->vector->toArray()); + $this->assertSame(range(1, 384), $iafv2->fresh()->vector->toArray()); } public function testHandlePatchOnly() @@ -571,7 +571,7 @@ public function testHandlePatchOnly() $prefix = fragment_uuid_path($annotation->image->uuid); $disk->assertExists("{$prefix}/{$annotation->id}.jpg"); $disk->assertMissing("{$prefix}/{$annotation->id}.svg"); - $this->assertEquals(0, ImageAnnotationLabelFeatureVector::count()); + $this->assertSame(0, ImageAnnotationLabelFeatureVector::count()); } public function testHandleFeatureVectorOnly() @@ -592,7 +592,7 @@ public function testHandleFeatureVectorOnly() $prefix = fragment_uuid_path($annotation->image->uuid); $disk->assertMissing("{$prefix}/{$annotation->id}.jpg"); $disk->assertMissing("{$prefix}/{$annotation->id}.svg"); - $this->assertEquals(1, ImageAnnotationLabelFeatureVector::count()); + $this->assertSame(1, ImageAnnotationLabelFeatureVector::count()); } public function testHandleSvgOnly() @@ -615,7 +615,7 @@ public function testHandleSvgOnly() $prefix = fragment_uuid_path($annotation->image->uuid); $disk->assertMissing("{$prefix}/{$annotation->id}.jpg"); $disk->assertExists("{$prefix}/{$annotation->id}.svg"); - $this->assertEquals(0, ImageAnnotationLabelFeatureVector::count()); + $this->assertSame(0, ImageAnnotationLabelFeatureVector::count()); } public function testHandleMultipleAnnotations() @@ -652,7 +652,7 @@ public function testHandleMultipleAnnotations() $disk->assertExists("{$prefix}/{$annotation2->id}.jpg"); $disk->assertExists("{$prefix}/{$annotation1->id}.svg"); $disk->assertExists("{$prefix}/{$annotation2->id}.svg"); - $this->assertEquals(2, ImageAnnotationLabelFeatureVector::count()); + $this->assertSame(2, ImageAnnotationLabelFeatureVector::count()); } public function testHandleOnlyAnnotations() @@ -686,7 +686,7 @@ public function testHandleOnlyAnnotations() $disk->assertExists("{$prefix}/{$annotation1->id}.svg"); $disk->assertMissing("{$prefix}/{$annotation2->id}.jpg"); $disk->assertMissing("{$prefix}/{$annotation2->id}.svg"); - $this->assertEquals(1, ImageAnnotationLabelFeatureVector::count()); + $this->assertSame(1, ImageAnnotationLabelFeatureVector::count()); } public function testHandleInvalidShape() @@ -743,7 +743,7 @@ public function testHandleFeatureVectorTiledImage() $job->handle(); $prefix = fragment_uuid_path($annotation->image->uuid); - $this->assertEquals(1, ImageAnnotationLabelFeatureVector::count()); + $this->assertSame(1, ImageAnnotationLabelFeatureVector::count()); $input = $job->input; $this->assertCount(1, $input); @@ -751,7 +751,7 @@ public function testHandleFeatureVectorTiledImage() $this->assertArrayHasKey($annotation->id, $input[$filename]); $box = $input[$filename][$annotation->id]; // These are the coordinates of the cropped image. - $this->assertEquals([0, 0, 224, 224], $box); + $this->assertSame([0, 0, 224, 224], $box); } public function testHandleFeatureVectorTiledImageLargePatch() @@ -787,7 +787,7 @@ public function testHandleFeatureVectorTiledImageLargePatch() $job->handle(); $prefix = fragment_uuid_path($annotation->image->uuid); - $this->assertEquals(1, ImageAnnotationLabelFeatureVector::count()); + $this->assertSame(1, ImageAnnotationLabelFeatureVector::count()); $input = $job->input; $this->assertCount(1, $input); @@ -795,7 +795,7 @@ public function testHandleFeatureVectorTiledImageLargePatch() $this->assertArrayHasKey($annotation->id, $input[$filename]); $box = $input[$filename][$annotation->id]; // These are the coordinates of the cropped image. - $this->assertEquals([0, 0, 5000, 5000], $box); + $this->assertSame([0, 0, 5000, 5000], $box); } public function testHandleFlatLineStringVector() @@ -814,7 +814,7 @@ public function testHandleFlatLineStringVector() $filename = array_keys($input)[0]; $box = $input[$filename][$annotation->id]; // The height is padded to ensure a minimum size of 32 px. - $this->assertEquals([300, 284, 400, 316], $box); + $this->assertSame([300, 284, 400, 316], $box); } protected function getImageMock($times = 1) diff --git a/tests/Jobs/ProcessAnnotatedVideoTest.php b/tests/Jobs/ProcessAnnotatedVideoTest.php index cc572cd6..e19ad65d 100644 --- a/tests/Jobs/ProcessAnnotatedVideoTest.php +++ b/tests/Jobs/ProcessAnnotatedVideoTest.php @@ -51,7 +51,7 @@ public function testHandleStorage() $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.jpg"); - $this->assertEquals('abc123', $content); + $this->assertSame('abc123', $content); // SVGs are not generated for whole frame annotations. $disk->assertMissing("{$prefix}/v-{$annotation->id}.svg"); } @@ -77,7 +77,7 @@ public function testHandleStorageConfigurableDisk() $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.jpg"); - $this->assertEquals('abc123', $content); + $this->assertSame('abc123', $content); // SVGs are not generated for whole frame annotations. $disk->assertMissing("{$prefix}/v-{$annotation->id}.svg"); } @@ -106,12 +106,12 @@ public function testHandlePoint() $video->shouldReceive('writeToBuffer')->once()->andReturn('abc123'); $job->handle(); - $this->assertEquals([1], $job->times); + $this->assertSame([1.0], $job->times); $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleCircle() @@ -139,12 +139,12 @@ public function testHandleCircle() $video->shouldReceive('writeToBuffer')->once()->andReturn('abc123'); $job->handle(); - $this->assertEquals([1], $job->times); + $this->assertSame([1.0], $job->times); $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandlePolygon() @@ -179,7 +179,7 @@ public function testHandlePolygon() $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleLineString() @@ -212,7 +212,7 @@ public function testHandleLineString() $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleRectangle() @@ -242,7 +242,7 @@ public function testHandleRectangle() $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleEllipse() @@ -272,7 +272,7 @@ public function testHandleEllipse() $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleSingleFrame() @@ -298,12 +298,12 @@ public function testHandleSingleFrame() $video->shouldReceive('writeToBuffer')->once()->andReturn('abc123'); $job->handle(); - $this->assertEquals([1], $job->times); + $this->assertSame([1.0], $job->times); $prefix = fragment_uuid_path($annotation->video->uuid); $content = $disk->get("{$prefix}/v-{$annotation->id}.svg"); $svg = ''; - $this->assertEquals($svg, $content); + $this->assertSame($svg, $content); } public function testHandleContainedNegative() @@ -329,7 +329,7 @@ public function testHandleContainedNegative() $video->shouldReceive('writeToBuffer')->once()->andReturn('abc123'); $job->handle(); - $this->assertEquals([1], $job->times); + $this->assertSame([1.0], $job->times); } public function testHandleContainedPositive() @@ -355,7 +355,7 @@ public function testHandleContainedPositive() $video->shouldReceive('writeToBuffer')->once()->andReturn('abc123'); $job->handle(); - $this->assertEquals([1], $job->times); + $this->assertSame([1.0], $job->times); } public function testHandleContainedTooLarge() @@ -384,7 +384,7 @@ public function testHandleContainedTooLarge() $video->shouldReceive('writeToBuffer')->once()->andReturn('abc123'); $job->handle(); - $this->assertEquals([1], $job->times); + $this->assertSame([1.0], $job->times); } public function testHandleMinDimension() @@ -509,15 +509,15 @@ public function testGenerateFeatureVectorNew() $filename = array_keys($input)[0]; $this->assertArrayHasKey($annotation->id, $input[$filename]); $box = $input[$filename][$annotation->id]; - $this->assertEquals([88, 88, 312, 312], $box); + $this->assertSame([88, 88, 312, 312], $box); $vectors = VideoAnnotationLabelFeatureVector::where('annotation_id', $annotation->id)->get(); $this->assertCount(1, $vectors); - $this->assertEquals($annotationLabel->id, $vectors[0]->id); - $this->assertEquals($annotationLabel->label_id, $vectors[0]->label_id); - $this->assertEquals($annotationLabel->label->label_tree_id, $vectors[0]->label_tree_id); - $this->assertEquals($annotation->video->volume_id, $vectors[0]->volume_id); - $this->assertEquals(range(0, 383), $vectors[0]->vector->toArray()); + $this->assertSame($annotationLabel->id, $vectors[0]->id); + $this->assertSame($annotationLabel->label_id, $vectors[0]->label_id); + $this->assertSame($annotationLabel->label->label_tree_id, $vectors[0]->label_tree_id); + $this->assertSame($annotation->video->volume_id, $vectors[0]->volume_id); + $this->assertSame(range(0, 383), $vectors[0]->vector->toArray()); } public function testGenerateFeatureVectorManyLabels() @@ -544,13 +544,13 @@ public function testGenerateFeatureVectorManyLabels() $vectors = VideoAnnotationLabelFeatureVector::where('annotation_id', $annotation->id)->get(); $this->assertCount(2, $vectors); - $this->assertEquals($annotationLabel1->id, $vectors[0]->id); - $this->assertEquals($annotationLabel1->label_id, $vectors[0]->label_id); - $this->assertEquals(range(0, 383), $vectors[0]->vector->toArray()); + $this->assertSame($annotationLabel1->id, $vectors[0]->id); + $this->assertSame($annotationLabel1->label_id, $vectors[0]->label_id); + $this->assertSame(range(0, 383), $vectors[0]->vector->toArray()); - $this->assertEquals($annotationLabel2->id, $vectors[1]->id); - $this->assertEquals($annotationLabel2->label_id, $vectors[1]->label_id); - $this->assertEquals(range(0, 383), $vectors[1]->vector->toArray()); + $this->assertSame($annotationLabel2->id, $vectors[1]->id); + $this->assertSame($annotationLabel2->label_id, $vectors[1]->label_id); + $this->assertSame(range(0, 383), $vectors[1]->vector->toArray()); } public function testGenerateFeatureVectorUpdate() @@ -588,9 +588,9 @@ public function testGenerateFeatureVectorUpdate() $job->handle(); $count = VideoAnnotationLabelFeatureVector::count(); - $this->assertEquals(2, $count); - $this->assertEquals(range(1, 384), $iafv->fresh()->vector->toArray()); - $this->assertEquals(range(1, 384), $iafv2->fresh()->vector->toArray()); + $this->assertSame(2, $count); + $this->assertSame(range(1, 384), $iafv->fresh()->vector->toArray()); + $this->assertSame(range(1, 384), $iafv2->fresh()->vector->toArray()); } public function testGenerateFeatureVectorWholeFrame() @@ -622,7 +622,7 @@ public function testGenerateFeatureVectorWholeFrame() $filename = array_keys($input)[0]; $this->assertArrayHasKey($annotation->id, $input[$filename]); $box = $input[$filename][$annotation->id]; - $this->assertEquals([0, 0, 1000, 750], $box); + $this->assertSame([0, 0, 1000, 750], $box); } public function testHandlePatchOnly() @@ -649,7 +649,7 @@ public function testHandlePatchOnly() $prefix = fragment_uuid_path($annotation->video->uuid); $disk->assertExists("{$prefix}/v-{$annotation->id}.jpg"); $disk->assertMissing("{$prefix}/v-{$annotation->id}.svg"); - $this->assertEquals(0, VideoAnnotationLabelFeatureVector::count()); + $this->assertSame(0, VideoAnnotationLabelFeatureVector::count()); } public function testHandleFeatureVectorOnly() @@ -673,7 +673,7 @@ public function testHandleFeatureVectorOnly() $prefix = fragment_uuid_path($annotation->video->uuid); $disk->assertMissing("{$prefix}/v-{$annotation->id}.jpg"); $disk->assertMissing("{$prefix}/v-{$annotation->id}.svg"); - $this->assertEquals(1, VideoAnnotationLabelFeatureVector::count()); + $this->assertSame(1, VideoAnnotationLabelFeatureVector::count()); } public function testHandleSvgOnly() @@ -698,7 +698,7 @@ public function testHandleSvgOnly() $prefix = fragment_uuid_path($annotation->video->uuid); $disk->assertMissing("{$prefix}/v-{$annotation->id}.jpg"); $disk->assertExists("{$prefix}/v-{$annotation->id}.svg"); - $this->assertEquals(0, VideoAnnotationLabelFeatureVector::count()); + $this->assertSame(0, VideoAnnotationLabelFeatureVector::count()); } public function testHandleMultipleAnnotations() @@ -737,7 +737,7 @@ public function testHandleMultipleAnnotations() $disk->assertExists("{$prefix}/v-{$annotation2->id}.jpg"); $disk->assertExists("{$prefix}/v-{$annotation1->id}.svg"); $disk->assertExists("{$prefix}/v-{$annotation2->id}.svg"); - $this->assertEquals(2, VideoAnnotationLabelFeatureVector::count()); + $this->assertSame(2, VideoAnnotationLabelFeatureVector::count()); } public function testHandleOnlyAnnotations() @@ -773,7 +773,7 @@ public function testHandleOnlyAnnotations() $disk->assertExists("{$prefix}/v-{$annotation1->id}.svg"); $disk->assertMissing("{$prefix}/v-{$annotation2->id}.jpg"); $disk->assertMissing("{$prefix}/v-{$annotation2->id}.svg"); - $this->assertEquals(1, VideoAnnotationLabelFeatureVector::count()); + $this->assertSame(1, VideoAnnotationLabelFeatureVector::count()); } public function testHandleInvalidShape() @@ -857,7 +857,7 @@ public function testHandleFlatLineStringVector() $input = $job->input; $filename = array_keys($input)[0]; $box = $input[$filename][$annotation->id]; - $this->assertEquals([300, 284, 400, 316], $box); + $this->assertSame([300, 284, 400, 316], $box); } protected function getFrameMock($times = 1) diff --git a/tests/Listeners/AttachLabelListenerTest.php b/tests/Listeners/AttachLabelListenerTest.php index 6fab02b7..2f49fac1 100644 --- a/tests/Listeners/AttachLabelListenerTest.php +++ b/tests/Listeners/AttachLabelListenerTest.php @@ -20,7 +20,7 @@ public function testHandleImageAnnotationLabel() with(new AttachLabelListener)->handle(new AnnotationLabelAttached($al)); Queue::assertPushed(function (CopyImageAnnotationFeatureVector $job) use ($al) { - $this->assertEquals($al, $job->annotationLabel); + $this->assertSame($al, $job->annotationLabel); return true; }); @@ -33,7 +33,7 @@ public function testHandleVideoAnnotationLabel() with(new AttachLabelListener)->handle(new AnnotationLabelAttached($al)); Queue::assertPushed(function (CopyVideoAnnotationFeatureVector $job) use ($al) { - $this->assertEquals($al, $job->annotationLabel); + $this->assertSame($al, $job->annotationLabel); return true; }); diff --git a/tests/Listeners/ImagesCleanupListenerTest.php b/tests/Listeners/ImagesCleanupListenerTest.php index 857a1e6c..0621079e 100644 --- a/tests/Listeners/ImagesCleanupListenerTest.php +++ b/tests/Listeners/ImagesCleanupListenerTest.php @@ -48,7 +48,7 @@ public function testHandle() ]; Queue::assertPushed(function (RemoveImageAnnotationPatches $job) use ($expect) { - $this->assertEquals($expect, $job->annotationIds); + $this->assertSame($expect, $job->annotationIds); return true; }); @@ -68,7 +68,7 @@ public function testPartial() ]; Queue::assertPushed(function (RemoveImageAnnotationPatches $job) use ($expect) { - $this->assertEquals($expect, $job->annotationIds); + $this->assertSame($expect, $job->annotationIds); return true; }); diff --git a/tests/Listeners/VideosCleanupListenerTest.php b/tests/Listeners/VideosCleanupListenerTest.php index c9df3908..fc41098e 100644 --- a/tests/Listeners/VideosCleanupListenerTest.php +++ b/tests/Listeners/VideosCleanupListenerTest.php @@ -48,7 +48,7 @@ public function testHandle() ]; Queue::assertPushed(function (RemoveVideoAnnotationPatches $job) use ($expect) { - $this->assertEquals($expect, $job->annotationIds); + $this->assertSame($expect, $job->annotationIds); return true; }); @@ -68,7 +68,7 @@ public function testPartial() ]; Queue::assertPushed(function (RemoveVideoAnnotationPatches $job) use ($expect) { - $this->assertEquals($expect, $job->annotationIds); + $this->assertSame($expect, $job->annotationIds); return true; });