Skip to content

Commit 1971d62

Browse files
authored
Merge pull request #178 from biigle/use-assertSame
Replace assertEquals by assertSame
2 parents e3f5ce2 + 78a9d6e commit 1971d62

19 files changed

+182
-182
lines changed

.github/workflows/test.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ jobs:
5858
docker pull ghcr.io/biigle/worker:latest
5959
6060
- name: Start test database
61-
run: docker-compose up -d --no-build database_testing && sleep 5
61+
run: docker compose up -d --no-build database_testing && sleep 5
6262
working-directory: ../core
6363

6464
- name: Run tests
65-
run: docker-compose run --rm -u 1001 worker php -d memory_limit=1G vendor/bin/phpunit --random-order --filter 'Biigle\\Tests\\Modules\\'${MODULE_NAME}
65+
run: docker compose run --rm -u 1001 worker php -d memory_limit=1G vendor/bin/phpunit --random-order --filter 'Biigle\\Tests\\Modules\\'${MODULE_NAME}
6666
working-directory: ../core

tests/AnnotationCandidateTest.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,22 @@ public function testAttributes()
3636
public function testCastPoints()
3737
{
3838
$annotation = static::create(['points' => [1, 2, 3, 4]]);
39-
$this->assertEquals([1, 2, 3, 4], $annotation->fresh()->points);
39+
$this->assertSame([1, 2, 3, 4], $annotation->fresh()->points);
4040
}
4141

4242
public function testGetPoints()
4343
{
4444
$annotation = static::make(['points' => [1, 2]]);
45-
$this->assertEquals([1, 2], $annotation->getPoints());
45+
$this->assertSame([1, 2], $annotation->getPoints());
4646
}
4747

4848
public function testGetShape()
4949
{
50-
$this->assertEquals($this->model->shape, $this->model->getShape());
50+
$this->assertSame($this->model->shape, $this->model->getShape());
5151
}
5252

5353
public function testGetFile()
5454
{
55-
$this->assertEquals($this->model->image, $this->model->getFile());
55+
$this->assertSame($this->model->image, $this->model->getFile());
5656
}
5757
}

tests/GenericImageTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function testInstance()
1717
public function testAttributes()
1818
{
1919
$i = new GenericImage(1, 'url');
20-
$this->assertEquals(1, $i->getId());
21-
$this->assertEquals('url', $i->getUrl());
20+
$this->assertSame(1, $i->getId());
21+
$this->assertSame('url', $i->getUrl());
2222
}
2323
}

tests/Http/Controllers/Api/AnnotationCandidateControllerTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function testUpdate()
106106
->assertStatus(200);
107107

108108
$a->refresh();
109-
$this->assertEquals([10, 20, 30], $a->points);
109+
$this->assertSame([10, 20, 30], $a->points);
110110
}
111111

112112
public function testUpdateLabel()
@@ -134,7 +134,7 @@ public function testUpdateLabel()
134134
])
135135
->assertStatus(200);
136136

137-
$this->assertEquals($this->labelRoot()->id, $a->fresh()->label_id);
137+
$this->assertSame($this->labelRoot()->id, $a->fresh()->label_id);
138138

139139
$this->putJson("/api/v1/maia/annotation-candidates/{$a->id}", [
140140
'label_id' => null,
@@ -172,7 +172,7 @@ public function testUpdatePoints()
172172
->assertStatus(200);
173173

174174
Queue::assertPushed(ProcessObjectDetectedImage::class, function ($job) use ($a) {
175-
$this->assertEquals([$a->id], $job->only);
175+
$this->assertSame([$a->id], $job->only);
176176
$this->assertFalse($job->skipFeatureVectors);
177177

178178
return true;

tests/Http/Controllers/Api/MaiaJobControllerTest.php

+17-17
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ public function testStoreNoveltyDetection()
8484

8585
$job = MaiaJob::first();
8686
$this->assertNotNull($job);
87-
$this->assertEquals($id, $job->volume_id);
88-
$this->assertEquals($this->editor()->id, $job->user_id);
89-
$this->assertEquals(State::noveltyDetectionId(), $job->state_id);
90-
$this->assertEquals($this->defaultParams, $job->params);
87+
$this->assertSame($id, $job->volume_id);
88+
$this->assertSame($this->editor()->id, $job->user_id);
89+
$this->assertSame(State::noveltyDetectionId(), $job->state_id);
90+
$this->assertSame($this->defaultParams, $job->params);
9191

9292
// only one running job at a time
9393
$this->postJson("/api/v1/volumes/{$id}/maia-jobs", $this->defaultParams)
@@ -249,7 +249,7 @@ public function testStoreUseExistingAnnotations()
249249
$job = MaiaJob::first();
250250
$this->assertTrue($job->shouldUseExistingAnnotations());
251251
$this->assertFalse($job->shouldShowTrainingProposals());
252-
$this->assertEquals(State::objectDetectionId(), $job->state_id);
252+
$this->assertSame(State::objectDetectionId(), $job->state_id);
253253
}
254254

255255
public function testStoreExistingAnnotationsRestrictLabels()
@@ -295,7 +295,7 @@ public function testStoreExistingAnnotationsRestrictLabels()
295295
->assertSuccessful();
296296
$job = MaiaJob::first();
297297
$this->assertArrayHasKey('oa_restrict_labels', $job->params);
298-
$this->assertEquals([$this->labelChild()->id], $job->params['oa_restrict_labels']);
298+
$this->assertSame([$this->labelChild()->id], $job->params['oa_restrict_labels']);
299299
}
300300

301301
public function testStoreUseExistingAnnotationsShowTrainingProposals()
@@ -329,7 +329,7 @@ public function testStoreUseExistingAnnotationsShowTrainingProposals()
329329
$job = MaiaJob::first();
330330
$this->assertTrue($job->shouldUseExistingAnnotations());
331331
$this->assertTrue($job->shouldShowTrainingProposals());
332-
$this->assertEquals(State::noveltyDetectionId(), $job->state_id);
332+
$this->assertSame(State::noveltyDetectionId(), $job->state_id);
333333
}
334334

335335
public function testStoreNdClustersTooFewImages()
@@ -407,9 +407,9 @@ public function testStoreKnowledgeTransfer()
407407

408408
$job = MaiaJob::first();
409409
$this->assertTrue($job->shouldUseKnowledgeTransfer());
410-
$this->assertEquals(State::objectDetectionId(), $job->state_id);
410+
$this->assertSame(State::objectDetectionId(), $job->state_id);
411411
$this->assertArrayHasKey('kt_volume_id', $job->params);
412-
$this->assertEquals($volume->id, $job->params['kt_volume_id']);
412+
$this->assertSame($volume->id, $job->params['kt_volume_id']);
413413
}
414414

415415
public function testStoreKnowledgeTransferRestrictLabels()
@@ -471,11 +471,11 @@ public function testStoreKnowledgeTransferRestrictLabels()
471471

472472
$job = MaiaJob::first();
473473
$this->assertTrue($job->shouldUseKnowledgeTransfer());
474-
$this->assertEquals(State::objectDetectionId(), $job->state_id);
474+
$this->assertSame(State::objectDetectionId(), $job->state_id);
475475
$this->assertArrayHasKey('kt_volume_id', $job->params);
476-
$this->assertEquals($volume->id, $job->params['kt_volume_id']);
476+
$this->assertSame($volume->id, $job->params['kt_volume_id']);
477477
$this->assertArrayHasKey('kt_restrict_labels', $job->params);
478-
$this->assertEquals([$ia->label_id], $job->params['kt_restrict_labels']);
478+
$this->assertSame([$ia->label_id], $job->params['kt_restrict_labels']);
479479
}
480480

481481
public function testStoreAreaKnowledgeTransfer()
@@ -544,9 +544,9 @@ public function testStoreAreaKnowledgeTransfer()
544544

545545
$job = MaiaJob::first();
546546
$this->assertTrue($job->shouldUseKnowledgeTransfer());
547-
$this->assertEquals(State::objectDetectionId(), $job->state_id);
547+
$this->assertSame(State::objectDetectionId(), $job->state_id);
548548
$this->assertArrayHasKey('kt_volume_id', $job->params);
549-
$this->assertEquals($volume->id, $job->params['kt_volume_id']);
549+
$this->assertSame($volume->id, $job->params['kt_volume_id']);
550550
}
551551

552552
public function testStoreAreaKnowledgeTransferLaserPointsFallback()
@@ -646,11 +646,11 @@ public function testStoreAreaKnowledgeTransferRestrictLabels()
646646

647647
$job = MaiaJob::first();
648648
$this->assertTrue($job->shouldUseKnowledgeTransfer());
649-
$this->assertEquals(State::objectDetectionId(), $job->state_id);
649+
$this->assertSame(State::objectDetectionId(), $job->state_id);
650650
$this->assertArrayHasKey('kt_volume_id', $job->params);
651-
$this->assertEquals($volume->id, $job->params['kt_volume_id']);
651+
$this->assertSame($volume->id, $job->params['kt_volume_id']);
652652
$this->assertArrayHasKey('kt_restrict_labels', $job->params);
653-
$this->assertEquals([$ia->label_id], $job->params['kt_restrict_labels']);
653+
$this->assertSame([$ia->label_id], $job->params['kt_restrict_labels']);
654654
}
655655

656656
public function testDestroy()

tests/Http/Controllers/Api/TrainingProposalControllerTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testSubmit()
7070
Event::fake();
7171
$this->postJson("/api/v1/maia-jobs/{$job->id}/training-proposals")->assertStatus(200);
7272
Event::assertDispatched(MaiaJobContinued::class);
73-
$this->assertEquals(State::objectDetectionId(), $job->fresh()->state_id);
73+
$this->assertSame(State::objectDetectionId(), $job->fresh()->state_id);
7474

7575
// Job is no longer in training proposal state.
7676
$this->postJson("/api/v1/maia-jobs/{$job->id}/training-proposals")->assertStatus(422);
@@ -116,7 +116,7 @@ public function testUpdate()
116116

117117
$a->refresh();
118118
$this->assertTrue($a->selected);
119-
$this->assertEquals([10, 20, 30], $a->points);
119+
$this->assertSame([10, 20, 30], $a->points);
120120
}
121121

122122
public function testUpdateAfterState()
@@ -154,7 +154,7 @@ public function testUpdatePoints()
154154
->assertStatus(200);
155155

156156
Queue::assertPushed(ProcessNoveltyDetectedImage::class, function ($job) use ($a) {
157-
$this->assertEquals([$a->id], $job->only);
157+
$this->assertSame([$a->id], $job->only);
158158
$this->assertFalse($job->skipFeatureVectors);
159159

160160
return true;

tests/Http/Requests/UpdateUserSettingsTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ public function testUpdate()
1717
$this->putJson("/api/v1/users/my/settings", ['maia_notifications' => 'email'])
1818
->assertStatus(200);
1919

20-
$this->assertEquals('email', $this->user()->fresh()->getSettings('maia_notifications'));
20+
$this->assertSame('email', $this->user()->fresh()->getSettings('maia_notifications'));
2121

2222
$this->putJson("/api/v1/users/my/settings", ['maia_notifications' => 'web'])
2323
->assertStatus(200);
2424

25-
$this->assertEquals('web', $this->user()->fresh()->getSettings('maia_notifications'));
25+
$this->assertSame('web', $this->user()->fresh()->getSettings('maia_notifications'));
2626
}
2727
}

tests/Jobs/ConvertAnnotationCandidatesTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ public function testHandle()
4040

4141
$a = $c1->fresh()->annotation;
4242
$this->assertNotNull($a);
43-
$this->assertEquals([1, 2, 3], $a->points);
43+
$this->assertSame([1, 2, 3], $a->points);
4444
$annotationLabel = $a->labels()->first();
45-
$this->assertEquals($label->id, $annotationLabel->label_id);
46-
$this->assertEquals($user->id, $annotationLabel->user_id);
45+
$this->assertSame($label->id, $annotationLabel->label_id);
46+
$this->assertSame($user->id, $annotationLabel->user_id);
4747

48-
$this->assertEquals($annotation->id, $c2->fresh()->annotation_id);
48+
$this->assertSame($annotation->id, $c2->fresh()->annotation_id);
4949

5050
Queue::assertPushed(ProcessAnnotatedImage::class, function ($job) use ($c1, $a) {
51-
$this->assertEquals($c1->image_id, $job->file->id);
52-
$this->assertEquals([$a->id], $job->only);
51+
$this->assertSame($c1->image_id, $job->file->id);
52+
$this->assertSame([$a->id], $job->only);
5353

5454
return true;
5555
});

tests/Jobs/GenerateAnnotationFeatureVectorsTest.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ public function testHandleTrainingProposals()
4545
$filename = array_keys($input)[0];
4646
$this->assertArrayHasKey($tp->id, $input[$filename]);
4747
$box = $input[$filename][$tp->id];
48-
$this->assertEquals([5, 5, 15, 15], $box);
48+
$this->assertSame([5, 5, 15, 15], $box);
4949

5050
$vectors = TrainingProposalFeatureVector::where('job_id', $j->id)->get();
5151
$this->assertCount(1, $vectors);
52-
$this->assertEquals($tp->id, $vectors[0]->id);
53-
$this->assertEquals(range(0, 383), $vectors[0]->vector->toArray());
52+
$this->assertSame($tp->id, $vectors[0]->id);
53+
$this->assertSame(range(0, 383), $vectors[0]->vector->toArray());
5454
}
5555

5656
public function testHandleAnnotationCandidates()
@@ -80,12 +80,12 @@ public function testHandleAnnotationCandidates()
8080
$filename = array_keys($input)[0];
8181
$this->assertArrayHasKey($ac->id, $input[$filename]);
8282
$box = $input[$filename][$ac->id];
83-
$this->assertEquals([5, 5, 15, 15], $box);
83+
$this->assertSame([5, 5, 15, 15], $box);
8484

8585
$vectors = AnnotationCandidateFeatureVector::where('job_id', $j->id)->get();
8686
$this->assertCount(1, $vectors);
87-
$this->assertEquals($ac->id, $vectors[0]->id);
88-
$this->assertEquals(range(0, 383), $vectors[0]->vector->toArray());
87+
$this->assertSame($ac->id, $vectors[0]->id);
88+
$this->assertSame(range(0, 383), $vectors[0]->vector->toArray());
8989
}
9090

9191
public function testHandleConvertPoint()
@@ -112,7 +112,7 @@ public function testHandleConvertPoint()
112112
$filename = array_keys($input)[0];
113113
$this->assertArrayHasKey($tp->id, $input[$filename]);
114114
$box = $input[$filename][$tp->id];
115-
$this->assertEquals([188, 188, 412, 412], $box);
115+
$this->assertSame([188, 188, 412, 412], $box);
116116
}
117117

118118
public function testHandleConvertRectangle()
@@ -139,7 +139,7 @@ public function testHandleConvertRectangle()
139139
$filename = array_keys($input)[0];
140140
$this->assertArrayHasKey($tp->id, $input[$filename]);
141141
$box = $input[$filename][$tp->id];
142-
$this->assertEquals([10, 10, 20, 20], $box);
142+
$this->assertSame([10, 10, 20, 20], $box);
143143
}
144144

145145
public function testHandleConvertLineString()
@@ -166,7 +166,7 @@ public function testHandleConvertLineString()
166166
$filename = array_keys($input)[0];
167167
$this->assertArrayHasKey($tp->id, $input[$filename]);
168168
$box = $input[$filename][$tp->id];
169-
$this->assertEquals([10, 10, 20, 20], $box);
169+
$this->assertSame([10, 10, 20, 20], $box);
170170
}
171171

172172
public function testHandleConvertEllipse()
@@ -193,7 +193,7 @@ public function testHandleConvertEllipse()
193193
$filename = array_keys($input)[0];
194194
$this->assertArrayHasKey($tp->id, $input[$filename]);
195195
$box = $input[$filename][$tp->id];
196-
$this->assertEquals([10, 10, 20, 20], $box);
196+
$this->assertSame([10, 10, 20, 20], $box);
197197
}
198198

199199
public function testHandleConvertPolygon()
@@ -220,7 +220,7 @@ public function testHandleConvertPolygon()
220220
$filename = array_keys($input)[0];
221221
$this->assertArrayHasKey($tp->id, $input[$filename]);
222222
$box = $input[$filename][$tp->id];
223-
$this->assertEquals([10, 10, 20, 20], $box);
223+
$this->assertSame([10, 10, 20, 20], $box);
224224
}
225225

226226
public function testHandleCoodinatesOutsideImageNegative()
@@ -247,7 +247,7 @@ public function testHandleCoodinatesOutsideImageNegative()
247247
$filename = array_keys($input)[0];
248248
$this->assertArrayHasKey($tp->id, $input[$filename]);
249249
$box = $input[$filename][$tp->id];
250-
$this->assertEquals([0, 0, 30, 30], $box);
250+
$this->assertSame([0, 0, 30, 30], $box);
251251
}
252252

253253
public function testHandleCoodinatesOutsideImageNegativeProblematic()
@@ -280,7 +280,7 @@ public function testHandleCoodinatesOutsideImageNegativeProblematic()
280280
$this->assertArrayHasKey($tp->id, $input[$filename]);
281281
$box = $input[$filename][$tp->id];
282282
// Moving the box outside negative space makes it overflow in the positive space.
283-
$this->assertEquals([0, 0, 25, 25], $box);
283+
$this->assertSame([0, 0, 25, 25], $box);
284284
}
285285

286286
public function testHandleCoodinatesOutsideImagePositive()
@@ -312,7 +312,7 @@ public function testHandleCoodinatesOutsideImagePositive()
312312
$filename = array_keys($input)[0];
313313
$this->assertArrayHasKey($tp->id, $input[$filename]);
314314
$box = $input[$filename][$tp->id];
315-
$this->assertEquals([70, 70, 100, 100], $box);
315+
$this->assertSame([70, 70, 100, 100], $box);
316316
}
317317

318318
public function testHandleCoodinatesOutsideImagePositiveProblematic()
@@ -345,7 +345,7 @@ public function testHandleCoodinatesOutsideImagePositiveProblematic()
345345
$this->assertArrayHasKey($tp->id, $input[$filename]);
346346
$box = $input[$filename][$tp->id];
347347
// Moving the box outside positive space makes it overflow in the negative space.
348-
$this->assertEquals([0, 0, 25, 25], $box);
348+
$this->assertSame([0, 0, 25, 25], $box);
349349
}
350350

351351
public function testHandleCoodinatesOutsideImageBoth()
@@ -377,7 +377,7 @@ public function testHandleCoodinatesOutsideImageBoth()
377377
$filename = array_keys($input)[0];
378378
$this->assertArrayHasKey($tp->id, $input[$filename]);
379379
$box = $input[$filename][$tp->id];
380-
$this->assertEquals([0, 0, 100, 100], $box);
380+
$this->assertSame([0, 0, 100, 100], $box);
381381
}
382382
}
383383

tests/Jobs/NoveltyDetectionFailureTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function testHandle()
2525
Notification::assertSentTo($job->user, NoveltyDetectionFailed::class);
2626

2727
$job->refresh();
28-
$this->assertEquals(State::failedNoveltyDetectionId(), $job->state_id);
29-
$this->assertEquals('This is the message.', $job->error['message']);
28+
$this->assertSame(State::failedNoveltyDetectionId(), $job->state_id);
29+
$this->assertSame('This is the message.', $job->error['message']);
3030
}
3131
}

0 commit comments

Comments
 (0)