From 89369af2047d68aed8fba206ca25d74230cde9f8 Mon Sep 17 00:00:00 2001 From: Leane Schlundt Date: Mon, 19 Aug 2024 09:48:01 +0200 Subject: [PATCH 1/5] Replace assertEquals by assertSame Use strong check for checking equality. --- tests/php/AnnotationSessionTest.php | 6 +- tests/php/AnnouncementTest.php | 8 +- .../Commands/PruneNotificationsTest.php | 2 +- tests/php/FederatedSearchInstanceTest.php | 8 +- .../Api/AnnotationSessionControllerTest.php | 6 +- .../Api/AnnouncementControllerTest.php | 2 +- .../Api/ApiTokenControllerTest.php | 4 +- .../FederatedSearchInstanceControllerTest.php | 22 ++--- .../Api/ImageAnnotationBulkControllerTest.php | 14 +-- .../Api/ImageAnnotationControllerTest.php | 14 +-- .../ImageAnnotationLabelControllerTest.php | 12 +-- .../Controllers/Api/ImageControllerTest.php | 2 +- .../Api/ImageLabelControllerTest.php | 8 +- .../Controllers/Api/LabelControllerTest.php | 6 +- ...belTreeAuthorizedProjectControllerTest.php | 24 ++--- .../Api/LabelTreeControllerTest.php | 38 ++++---- .../Api/LabelTreeLabelControllerTest.php | 10 +- .../Api/LabelTreeUserControllerTest.php | 16 ++-- .../Api/LabelTreeVersionControllerTest.php | 16 ++-- .../Api/LinkVideoAnnotationControllerTest.php | 24 ++--- .../Api/NotificationControllerTest.php | 12 +-- .../Controllers/Api/ProjectControllerTest.php | 8 +- .../Api/ProjectInvitationControllerTest.php | 20 ++-- .../Api/ProjectLabelTreeControllerTest.php | 6 +- .../Api/ProjectUserControllerTest.php | 8 +- .../Api/ProjectVolumeControllerTest.php | 6 +- .../SplitVideoAnnotationControllerTest.php | 6 +- .../Controllers/Api/UserControllerTest.php | 40 ++++---- .../Api/UserRegistrationControllerTest.php | 2 +- .../Api/UserSettingsControllerTest.php | 2 +- .../Api/VideoAnnotationControllerTest.php | 30 +++--- .../VideoAnnotationLabelControllerTest.php | 4 +- .../Api/VideoFileControllerTest.php | 4 +- .../Api/VideoLabelControllerTest.php | 8 +- .../VolumeAnnotationSessionControllerTest.php | 2 +- .../Controllers/Api/VolumeControllerTest.php | 12 +-- .../Api/VolumeFileControllerTest.php | 12 +-- .../Api/Volumes/IfdoControllerTest.php | 2 +- .../Api/Volumes/MetadataControllerTest.php | 28 +++--- .../Http/Controllers/Auth/ControllerTest.php | 4 +- .../Auth/RegisterControllerTest.php | 34 +++---- tests/php/ImageAnnotationTest.php | 20 ++-- tests/php/ImageTest.php | 38 ++++---- tests/php/Jobs/CloneImagesOrVideosTest.php | 32 +++---- .../php/Jobs/CreateNewImagesOrVideosTest.php | 36 +++---- .../Jobs/GenerateFederatedSearchIndexTest.php | 14 +-- tests/php/Jobs/ProcessNewImageTest.php | 20 ++-- tests/php/Jobs/ProcessNewVideoTest.php | 28 +++--- tests/php/Jobs/TileSingleImageTest.php | 2 +- tests/php/Jobs/TrackObjectTest.php | 44 ++++----- .../Jobs/UpdateFederatedSearchIndexTest.php | 44 ++++----- tests/php/LabelSourceTest.php | 2 +- tests/php/LabelTest.php | 8 +- tests/php/LabelTreeTest.php | 32 +++---- tests/php/LabelTreeVersionTest.php | 2 +- tests/php/ProjectTest.php | 46 ++++----- tests/php/ProjectUserIntegrityTest.php | 8 +- tests/php/ProjectVolumeIntegrityTest.php | 4 +- tests/php/RoleTest.php | 8 +- tests/php/Rules/VolumeUrlTest.php | 4 +- tests/php/Services/Auth/ApiGuardTest.php | 2 +- .../LabelSourceAdapters/WormsAdapterTest.php | 26 +++--- tests/php/Services/ModulesTest.php | 8 +- tests/php/Traits/ParsesMetadataTest.php | 93 ++++++++++--------- tests/php/UserTest.php | 18 ++-- tests/php/VideoAnnotationTest.php | 22 ++--- tests/php/VideoTest.php | 34 +++---- tests/php/VisibilityTest.php | 4 +- tests/php/VolumeTest.php | 60 ++++++------ 69 files changed, 576 insertions(+), 575 deletions(-) diff --git a/tests/php/AnnotationSessionTest.php b/tests/php/AnnotationSessionTest.php index 9fe59cf0e..d1b3869b9 100644 --- a/tests/php/AnnotationSessionTest.php +++ b/tests/php/AnnotationSessionTest.php @@ -60,7 +60,7 @@ public function testUsers() $user = UserTest::create(); $this->model->users()->attach($user); $sessionUser = $this->model->users()->first(); - $this->assertEquals([ + $this->assertSame([ 'id' => $user->id, 'firstname' => $user->firstname, 'lastname' => $user->lastname, @@ -608,8 +608,8 @@ public function testStartsAtEndsAtISO8601() 'ends_at' => '2016-09-07T00:00:00.000+02:00', ]); - $this->assertEquals('2016-09-04T22:00:00+00:00', $session->starts_at_iso8601); - $this->assertEquals('2016-09-06T22:00:00+00:00', $session->ends_at_iso8601); + $this->assertSame('2016-09-04T22:00:00+00:00', $session->starts_at_iso8601); + $this->assertSame('2016-09-06T22:00:00+00:00', $session->ends_at_iso8601); $this->assertArrayHasKey('starts_at_iso8601', $session->toArray()); $this->assertArrayHasKey('ends_at_iso8601', $session->toArray()); diff --git a/tests/php/AnnouncementTest.php b/tests/php/AnnouncementTest.php index d57950585..bcc88d121 100644 --- a/tests/php/AnnouncementTest.php +++ b/tests/php/AnnouncementTest.php @@ -40,15 +40,15 @@ public function testScopeActive() { $this->model->show_until = '2022-10-20 16:17:00'; $this->model->save(); - $this->assertEquals(0, Announcement::active()->count()); + $this->assertSame(0, Announcement::active()->count()); $this->model->show_until = now()->addDay(); $this->model->save(); - $this->assertEquals(1, Announcement::active()->count()); + $this->assertSame(1, Announcement::active()->count()); $this->model->show_until = null; $this->model->save(); - $this->assertEquals(1, Announcement::active()->count()); + $this->assertSame(1, Announcement::active()->count()); } public function testGetActive() @@ -56,7 +56,7 @@ public function testGetActive() $this->model->show_until = now()->addDay(); $this->model->save(); - $this->assertEquals($this->model->id, Announcement::getActive()->id); + $this->assertSame($this->model->id, Announcement::getActive()->id); $this->model->delete(); $this->assertNull(Announcement::getActive()); diff --git a/tests/php/Console/Commands/PruneNotificationsTest.php b/tests/php/Console/Commands/PruneNotificationsTest.php index e01c79e28..49382704f 100644 --- a/tests/php/Console/Commands/PruneNotificationsTest.php +++ b/tests/php/Console/Commands/PruneNotificationsTest.php @@ -45,7 +45,7 @@ public function testHandle() ]); (new PruneNotifications)->handle(); - $this->assertEquals(2, DatabaseNotification::count()); + $this->assertSame(2, DatabaseNotification::count()); $this->assertNull(DatabaseNotification::find('1')); } } diff --git a/tests/php/FederatedSearchInstanceTest.php b/tests/php/FederatedSearchInstanceTest.php index 02af49d12..5aa2c1d3e 100644 --- a/tests/php/FederatedSearchInstanceTest.php +++ b/tests/php/FederatedSearchInstanceTest.php @@ -51,19 +51,19 @@ public function testScopeWithRemoteToken() public function testSetRemoteTokenAttribute() { $this->model->remote_token = 'test'; - $this->assertEquals('test', decrypt($this->model->getAttributes()['remote_token'])); + $this->assertSame('test', decrypt($this->model->getAttributes()['remote_token'])); } public function testGetRemoteTokenAttribute() { $this->model->setRawAttributes(['remote_token' => encrypt('test')]); - $this->assertEquals('test', $this->model->remote_token); + $this->assertSame('test', $this->model->remote_token); } public function testCreateLocalToken() { $token = $this->model->createLocalToken(); - $this->assertEquals(64, strlen($token)); - $this->assertEquals(hash('sha256', $token), $this->model->local_token); + $this->assertSame(64, strlen($token)); + $this->assertSame(hash('sha256', $token), $this->model->local_token); } } diff --git a/tests/php/Http/Controllers/Api/AnnotationSessionControllerTest.php b/tests/php/Http/Controllers/Api/AnnotationSessionControllerTest.php index a4a832659..4733fabfd 100644 --- a/tests/php/Http/Controllers/Api/AnnotationSessionControllerTest.php +++ b/tests/php/Http/Controllers/Api/AnnotationSessionControllerTest.php @@ -90,9 +90,9 @@ public function testUpdate() $session = $session->fresh(); - $this->assertEquals('my cool name', $session->name); - $this->assertEquals('2016-09-07', $session->ends_at->format('Y-m-d')); - $this->assertEquals([$this->admin()->id], $session->users()->pluck('id')->all()); + $this->assertSame('my cool name', $session->name); + $this->assertSame('2016-09-07', $session->ends_at->format('Y-m-d')); + $this->assertSame([$this->admin()->id], $session->users()->pluck('id')->all()); } public function testUpdateTimezones() diff --git a/tests/php/Http/Controllers/Api/AnnouncementControllerTest.php b/tests/php/Http/Controllers/Api/AnnouncementControllerTest.php index 48470812d..37702322a 100644 --- a/tests/php/Http/Controllers/Api/AnnouncementControllerTest.php +++ b/tests/php/Http/Controllers/Api/AnnouncementControllerTest.php @@ -40,7 +40,7 @@ public function testStore() // show_until must be in the future ->assertStatus(422); - $this->assertEquals(0, Announcement::count()); + $this->assertSame(0, Announcement::count()); $this ->json('POST', '/api/v1/announcements', [ diff --git a/tests/php/Http/Controllers/Api/ApiTokenControllerTest.php b/tests/php/Http/Controllers/Api/ApiTokenControllerTest.php index 04ac07497..11f5690cb 100644 --- a/tests/php/Http/Controllers/Api/ApiTokenControllerTest.php +++ b/tests/php/Http/Controllers/Api/ApiTokenControllerTest.php @@ -55,13 +55,13 @@ public function testStore() // missing purpose $response->assertStatus(422); - $this->assertEquals(1, $token->owner->apiTokens()->count()); + $this->assertSame(1, $token->owner->apiTokens()->count()); $response = $this->json('POST', '/api/v1/api-tokens', ['purpose' => 'abc']) ->assertJsonFragment(['purpose' => 'abc']); $response->assertSuccessful(); - $this->assertEquals(2, $token->owner->apiTokens()->count()); + $this->assertSame(2, $token->owner->apiTokens()->count()); $this->assertStringContainsString('"token":"', $response->getContent()); $response = $this->post('/api/v1/api-tokens', ['purpose' => 'def']) diff --git a/tests/php/Http/Controllers/Api/FederatedSearchInstanceControllerTest.php b/tests/php/Http/Controllers/Api/FederatedSearchInstanceControllerTest.php index cb758bcea..0273e59b4 100644 --- a/tests/php/Http/Controllers/Api/FederatedSearchInstanceControllerTest.php +++ b/tests/php/Http/Controllers/Api/FederatedSearchInstanceControllerTest.php @@ -49,8 +49,8 @@ public function testStore() $instance = FederatedSearchInstance::first(); $this->assertNotNull($instance); - $this->assertEquals('my instance', $instance->name); - $this->assertEquals('https://example.com', $instance->url); + $this->assertSame('my instance', $instance->name); + $this->assertSame('https://example.com', $instance->url); $this->assertNull($instance->local_token); $this->assertNull($instance->remote_token); $this->assertNull($instance->indexed_at); @@ -86,8 +86,8 @@ public function testUpdate() ->assertStatus(200); $instance->refresh(); - $this->assertEquals('my updated instance', $instance->name); - $this->assertEquals('https://www.example.com', $instance->url); + $this->assertSame('my updated instance', $instance->name); + $this->assertSame('https://www.example.com', $instance->url); } public function testUpdateSetRemoteToken() @@ -116,12 +116,12 @@ public function testUpdateSetRemoteToken() ]) ->assertStatus(200); - $this->assertEquals('mytoken', $instance->fresh()->remote_token); + $this->assertSame('mytoken', $instance->fresh()->remote_token); $this->assertCount(1, $container); $request = $container[0]['request']; - $this->assertEquals('https://example.com/api/v1/federated-search-index', strval($request->getUri())); - $this->assertEquals('Bearer mytoken', $request->getHeaderLine('Authorization')); - $this->assertEquals('HEAD', $request->getMethod()); + $this->assertSame('https://example.com/api/v1/federated-search-index', strval($request->getUri())); + $this->assertSame('Bearer mytoken', $request->getHeaderLine('Authorization')); + $this->assertSame('HEAD', $request->getMethod()); Bus::assertDispatched(UpdateFederatedSearchIndex::class); } @@ -254,9 +254,9 @@ public function testUpdateUrlWithRemoteToken() Bus::assertNotDispatched(UpdateFederatedSearchIndex::class); $this->assertCount(1, $container); $request = $container[0]['request']; - $this->assertEquals('https://www.example.com/api/v1/federated-search-index', strval($request->getUri())); - $this->assertEquals('Bearer mytoken', $request->getHeaderLine('Authorization')); - $this->assertEquals('HEAD', $request->getMethod()); + $this->assertSame('https://www.example.com/api/v1/federated-search-index', strval($request->getUri())); + $this->assertSame('Bearer mytoken', $request->getHeaderLine('Authorization')); + $this->assertSame('HEAD', $request->getMethod()); } public function testUpdateGetLocalToken() diff --git a/tests/php/Http/Controllers/Api/ImageAnnotationBulkControllerTest.php b/tests/php/Http/Controllers/Api/ImageAnnotationBulkControllerTest.php index d4e436504..2d9e63911 100644 --- a/tests/php/Http/Controllers/Api/ImageAnnotationBulkControllerTest.php +++ b/tests/php/Http/Controllers/Api/ImageAnnotationBulkControllerTest.php @@ -94,12 +94,12 @@ public function store($url) ]) ->assertStatus(200); - $this->assertEquals(3, $this->annotation->image->annotations()->count()); + $this->assertSame(3, $this->annotation->image->annotations()->count()); $annotation = $this->annotation->image->annotations()->orderBy('id', 'desc')->first(); - $this->assertEquals(Shape::pointId(), $annotation->shape_id); - $this->assertEquals([100, 100], $annotation->points); - $this->assertEquals(1, $annotation->labels()->count()); - $this->assertEquals($this->labelRoot()->id, $annotation->labels()->first()->label_id); + $this->assertSame(Shape::pointId(), $annotation->shape_id); + $this->assertSame([100, 100], $annotation->points); + $this->assertSame(1, $annotation->labels()->count()); + $this->assertSame($this->labelRoot()->id, $annotation->labels()->first()->label_id); } public function testStoreValidation() @@ -193,7 +193,7 @@ public function storeValidation($url) ]]) ->assertStatus(422); - $this->assertEquals(1, $this->annotation->image->annotations()->count()); + $this->assertSame(1, $this->annotation->image->annotations()->count()); $this ->postJson($url, [[ @@ -259,7 +259,7 @@ public function testStoreLabelIdIsString() ]) ->assertStatus(200); - $this->assertEquals(2, $this->annotation->image->annotations()->count()); + $this->assertSame(2, $this->annotation->image->annotations()->count()); } public function testStoreLabelIdIsFloat() diff --git a/tests/php/Http/Controllers/Api/ImageAnnotationControllerTest.php b/tests/php/Http/Controllers/Api/ImageAnnotationControllerTest.php index 3907af2ae..1ede2435e 100644 --- a/tests/php/Http/Controllers/Api/ImageAnnotationControllerTest.php +++ b/tests/php/Http/Controllers/Api/ImageAnnotationControllerTest.php @@ -285,8 +285,8 @@ public function testStore() $annotation = $this->image->annotations->first(); $this->assertNotNull($annotation); - $this->assertEquals(2, sizeof($annotation->points)); - $this->assertEquals(1, $annotation->labels()->count()); + $this->assertSame(2, sizeof($annotation->points)); + $this->assertSame(1, $annotation->labels()->count()); } public function testStoreValidatePoints() @@ -342,16 +342,16 @@ public function update($url) $this->annotation = $this->annotation->fresh(); - $this->assertEquals(4, sizeof($this->annotation->points)); - $this->assertEquals(15, $this->annotation->points[1]); + $this->assertSame(4, sizeof($this->annotation->points)); + $this->assertSame(15, $this->annotation->points[1]); $response = $this->json('PUT', "{$url}/{$id}", ['points' => [20, 25]]); $response->assertStatus(200); $this->annotation = $this->annotation->fresh(); - $this->assertEquals(2, sizeof($this->annotation->points)); - $this->assertEquals(25, $this->annotation->points[1]); + $this->assertSame(2, sizeof($this->annotation->points)); + $this->assertSame(25, $this->annotation->points[1]); } public function testUpdateInvalidPoints() @@ -429,7 +429,7 @@ public function updateChangeShape($url) ->assertStatus(200); $this->annotation->refresh(); - $this->assertEquals(Shape::circleId(), $this->annotation->shape_id); + $this->assertSame(Shape::circleId(), $this->annotation->shape_id); } public function testDestroy() diff --git a/tests/php/Http/Controllers/Api/ImageAnnotationLabelControllerTest.php b/tests/php/Http/Controllers/Api/ImageAnnotationLabelControllerTest.php index dba26c170..186c53fc7 100644 --- a/tests/php/Http/Controllers/Api/ImageAnnotationLabelControllerTest.php +++ b/tests/php/Http/Controllers/Api/ImageAnnotationLabelControllerTest.php @@ -129,7 +129,7 @@ public function store($url) ]); $response->assertStatus(422); - $this->assertEquals(0, $this->annotation->labels()->count()); + $this->assertSame(0, $this->annotation->labels()->count()); $this->beUser(); $response = $this->post("{$url}/{$id}/labels", [ @@ -151,7 +151,7 @@ public function store($url) 'confidence' => 0.1, ]); $response->assertStatus(201); - $this->assertEquals(1, $this->annotation->labels()->count()); + $this->assertSame(1, $this->annotation->labels()->count()); Event::assertDispatched(AnnotationLabelAttached::class); @@ -163,7 +163,7 @@ public function store($url) $response->assertStatus(201); Event::assertDispatched(AnnotationLabelAttached::class); - $this->assertEquals(2, $this->annotation->labels()->count()); + $this->assertSame(2, $this->annotation->labels()->count()); $response->assertJsonFragment([ 'id' => $this->labelRoot()->id, 'name' => $this->labelRoot()->name, @@ -184,7 +184,7 @@ public function store($url) ]); // the same user cannot attach the same label twice $response->assertStatus(400); - $this->assertEquals(2, $this->annotation->labels()->count()); + $this->assertSame(2, $this->annotation->labels()->count()); } public function testUpdate() @@ -225,14 +225,14 @@ public function update($url) $response = $this->put("{$url}/{$id}"); $response->assertStatus(200); - $this->assertEquals(0.5, $annotationLabel->fresh()->confidence); + $this->assertSame(0.5, $annotationLabel->fresh()->confidence); $this->beEditor(); $response = $this->put("{$url}/{$id}", [ '_token' => Session::token(), 'confidence' => 0.1, ]); $response->assertStatus(200); - $this->assertEquals(0.1, $annotationLabel->fresh()->confidence); + $this->assertSame(0.1, $annotationLabel->fresh()->confidence); } public function testDestroy() diff --git a/tests/php/Http/Controllers/Api/ImageControllerTest.php b/tests/php/Http/Controllers/Api/ImageControllerTest.php index cd3970fb7..898dc25ef 100644 --- a/tests/php/Http/Controllers/Api/ImageControllerTest.php +++ b/tests/php/Http/Controllers/Api/ImageControllerTest.php @@ -56,7 +56,7 @@ public function testShowFile() $response = $this->get("/api/v1/images/{$id}/file"); $response->assertStatus(200); - $this->assertEquals('image/jpeg', $response->headers->get('content-type')); + $this->assertSame('image/jpeg', $response->headers->get('content-type')); } public function testShowFileTiled() diff --git a/tests/php/Http/Controllers/Api/ImageLabelControllerTest.php b/tests/php/Http/Controllers/Api/ImageLabelControllerTest.php index 753f237f7..5d225d977 100644 --- a/tests/php/Http/Controllers/Api/ImageLabelControllerTest.php +++ b/tests/php/Http/Controllers/Api/ImageLabelControllerTest.php @@ -54,7 +54,7 @@ public function testStore() $response = $this->json('POST', "/api/v1/images/{$id}/labels"); $response->assertStatus(422); - $this->assertEquals(0, $this->image->labels()->count()); + $this->assertSame(0, $this->image->labels()->count()); $this->beUser(); $response = $this->post("/api/v1/images/{$id}/labels", [ @@ -73,7 +73,7 @@ public function testStore() 'label_id' => $this->labelRoot()->id, ]); $response->assertSuccessful(); - $this->assertEquals(1, $this->image->labels()->count()); + $this->assertSame(1, $this->image->labels()->count()); $this->beAdmin(); // the same label cannot be attached twice @@ -81,13 +81,13 @@ public function testStore() 'label_id' => $this->labelRoot()->id, ]); $response->assertStatus(400); - $this->assertEquals(1, $this->image->labels()->count()); + $this->assertSame(1, $this->image->labels()->count()); $response = $this->json('POST', "/api/v1/images/{$id}/labels", [ 'label_id' => $this->labelChild()->id, ]); $response->assertSuccessful(); - $this->assertEquals(2, $this->image->labels()->count()); + $this->assertSame(2, $this->image->labels()->count()); $response->assertJsonFragment([ 'id' => $this->labelChild()->id, 'name' => $this->labelChild()->name, diff --git a/tests/php/Http/Controllers/Api/LabelControllerTest.php b/tests/php/Http/Controllers/Api/LabelControllerTest.php index ee35317ae..3e15b55bb 100644 --- a/tests/php/Http/Controllers/Api/LabelControllerTest.php +++ b/tests/php/Http/Controllers/Api/LabelControllerTest.php @@ -58,9 +58,9 @@ public function testUpdate() $response->assertStatus(200); $label = $label->fresh(); - $this->assertEquals('new label name', $label->name); - $this->assertEquals('bada55', $label->color); - $this->assertEquals($sibling->id, $label->parent_id); + $this->assertSame('new label name', $label->name); + $this->assertSame('bada55', $label->color); + $this->assertSame($sibling->id, $label->parent_id); } public function testUpdateVersionedTree() diff --git a/tests/php/Http/Controllers/Api/LabelTreeAuthorizedProjectControllerTest.php b/tests/php/Http/Controllers/Api/LabelTreeAuthorizedProjectControllerTest.php index 07d5c628d..ba29ae679 100644 --- a/tests/php/Http/Controllers/Api/LabelTreeAuthorizedProjectControllerTest.php +++ b/tests/php/Http/Controllers/Api/LabelTreeAuthorizedProjectControllerTest.php @@ -39,13 +39,13 @@ public function testStore() $response->assertStatus(200); $this->assertTrue($tree->authorizedProjects()->exists()); - $this->assertEquals(1, $tree->authorizedProjects()->count()); + $this->assertSame(1, $tree->authorizedProjects()->count()); $response = $this->json('POST', "/api/v1/label-trees/{$tree->id}/authorized-projects", [ 'id' => $this->project()->id, ]); // should not fail if same project is authorized twice but should not add it twice $response->assertStatus(200); - $this->assertEquals(1, $tree->authorizedProjects()->count()); + $this->assertSame(1, $tree->authorizedProjects()->count()); } public function testStoreFormRequest() @@ -57,7 +57,7 @@ public function testStoreFormRequest() $response = $this->post("/api/v1/label-trees/{$tree->id}/authorized-projects", [ 'id' => $this->project()->id, ]); - $this->assertEquals(1, $tree->authorizedProjects()->count()); + $this->assertSame(1, $tree->authorizedProjects()->count()); $response->assertRedirect('/'); $response->assertSessionHas('saved', true); @@ -65,7 +65,7 @@ public function testStoreFormRequest() 'id' => $this->project()->id, '_redirect' => 'settings', ]); - $this->assertEquals(1, $tree->authorizedProjects()->count()); + $this->assertSame(1, $tree->authorizedProjects()->count()); $response->assertRedirect('/settings'); $response->assertSessionHas('saved', true); } @@ -119,25 +119,25 @@ public function testDestroy() $response->assertStatus(403); $this->beAdmin(); - $this->assertEquals(1, $tree->authorizedProjects()->count()); - $this->assertEquals(1, $tree->projects()->count()); + $this->assertSame(1, $tree->authorizedProjects()->count()); + $this->assertSame(1, $tree->projects()->count()); $response = $this->json('DELETE', "/api/v1/label-trees/{$tree->id}/authorized-projects/{$project->id}"); $response->assertStatus(200); - $this->assertEquals(0, $tree->authorizedProjects()->count()); - $this->assertEquals(1, $tree->projects()->count()); + $this->assertSame(0, $tree->authorizedProjects()->count()); + $this->assertSame(1, $tree->projects()->count()); $tree->authorizedProjects()->attach($project->id); $tree->visibility_id = Visibility::privateId(); $tree->save(); - $this->assertEquals(1, $tree->authorizedProjects()->count()); - $this->assertEquals(1, $tree->projects()->count()); + $this->assertSame(1, $tree->authorizedProjects()->count()); + $this->assertSame(1, $tree->projects()->count()); $response = $this->json('DELETE', "/api/v1/label-trees/{$tree->id}/authorized-projects/{$project->id}"); // if the tree is private and project authorization is removed, the // tree should be removed from the project as well $response->assertStatus(200); - $this->assertEquals(0, $tree->authorizedProjects()->count()); - $this->assertEquals(0, $tree->projects()->count()); + $this->assertSame(0, $tree->authorizedProjects()->count()); + $this->assertSame(0, $tree->projects()->count()); } public function testDestroyFormRequest() diff --git a/tests/php/Http/Controllers/Api/LabelTreeControllerTest.php b/tests/php/Http/Controllers/Api/LabelTreeControllerTest.php index a3eb0ac3b..c0bbc1ae1 100644 --- a/tests/php/Http/Controllers/Api/LabelTreeControllerTest.php +++ b/tests/php/Http/Controllers/Api/LabelTreeControllerTest.php @@ -154,21 +154,21 @@ public function testUpdate() ]); $response->assertStatus(200); - $this->assertEquals('my test', $tree->fresh()->name); + $this->assertSame('my test', $tree->fresh()->name); $response = $this->json('PUT', "/api/v1/label-trees/{$id}", [ 'description' => 'this is my test', ]); $response->assertStatus(200); - $this->assertEquals('this is my test', $tree->fresh()->description); + $this->assertSame('this is my test', $tree->fresh()->description); $response = $this->json('PUT', "/api/v1/label-trees/{$id}", [ 'visibility_id' => Visibility::publicId(), ]); $response->assertStatus(200); - $this->assertEquals(Visibility::publicId(), $tree->fresh()->visibility_id); + $this->assertSame(Visibility::publicId(), $tree->fresh()->visibility_id); } public function testUpdateFormRequest() @@ -185,7 +185,7 @@ public function testUpdateFormRequest() $response = $this->put("/api/v1/label-trees/{$id}", [ 'name' => 'abc', ]); - $this->assertEquals('abc', $tree->fresh()->name); + $this->assertSame('abc', $tree->fresh()->name); $response->assertRedirect('/'); $response->assertSessionHas('saved', true); @@ -193,7 +193,7 @@ public function testUpdateFormRequest() 'description' => 'abc', '_redirect' => 'settings', ]); - $this->assertEquals('abc', $tree->fresh()->description); + $this->assertSame('abc', $tree->fresh()->description); $response->assertRedirect('/settings'); $response->assertSessionHas('saved', true); } @@ -217,7 +217,7 @@ public function testUpdateVisibility() 'visibility_id' => strval(Visibility::privateId()), ]); - $this->assertEquals($authorized->id, $tree->projects()->pluck('id')->first()); + $this->assertSame($authorized->id, $tree->projects()->pluck('id')->first()); } public function testUpdatePropagateVisibility() @@ -236,7 +236,7 @@ public function testUpdatePropagateVisibility() ]) ->assertStatus(200); - $this->assertEquals(Visibility::publicId(), $tree->fresh()->visibility_id); + $this->assertSame(Visibility::publicId(), $tree->fresh()->visibility_id); } public function testUpdatePropagateName() @@ -255,7 +255,7 @@ public function testUpdatePropagateName() ]) ->assertStatus(200); - $this->assertEquals('My Cool Tree', $tree->fresh()->name); + $this->assertSame('My Cool Tree', $tree->fresh()->name); } public function testStore() @@ -286,7 +286,7 @@ public function testStore() // visibility must exist $response->assertStatus(422); - $this->assertEquals(0, LabelTree::count()); + $this->assertSame(0, LabelTree::count()); $response = $this->json('POST', '/api/v1/label-trees', [ 'name' => 'abc', @@ -295,7 +295,7 @@ public function testStore() // description is optional $response->assertSuccessful(); - $this->assertEquals(1, LabelTree::count()); + $this->assertSame(1, LabelTree::count()); $response = $this->json('POST', '/api/v1/label-trees', [ 'name' => 'abc', @@ -305,7 +305,7 @@ public function testStore() ]); $response->assertSuccessful(); - $this->assertEquals(2, LabelTree::count()); + $this->assertSame(2, LabelTree::count()); $tree = LabelTree::orderBy('id', 'desc')->first(); $this->assertNotNull($tree->uuid); @@ -314,7 +314,7 @@ public function testStore() // creator gets first label tree admin $member = $tree->members()->find($this->user()->id); $this->assertNotNull($member); - $this->assertEquals(Role::adminId(), $member->role_id); + $this->assertSame(Role::adminId(), $member->role_id); } public function testStoreAuthorization() @@ -368,8 +368,8 @@ public function testStoreTargetProject() ]); $response->assertSuccessful(); $tree = LabelTree::first(); - $this->assertEquals($this->project()->id, $tree->projects()->first()->id); - $this->assertEquals($this->project()->id, $tree->authorizedProjects()->first()->id); + $this->assertSame($this->project()->id, $tree->projects()->first()->id); + $this->assertSame($this->project()->id, $tree->authorizedProjects()->first()->id); } public function testStoreFormRequest() @@ -381,7 +381,7 @@ public function testStoreFormRequest() 'visibility_id' => Visibility::publicId(), 'description' => 'my description', ]); - $this->assertEquals(1, LabelTree::count()); + $this->assertSame(1, LabelTree::count()); $response = $this->post('/api/v1/label-trees', [ 'name' => 'abc', @@ -389,7 +389,7 @@ public function testStoreFormRequest() 'description' => 'my description', '_redirect' => 'settings', ]); - $this->assertEquals(2, LabelTree::count()); + $this->assertSame(2, LabelTree::count()); $response->assertRedirect('/settings'); $response->assertSessionHas('newTree'); } @@ -443,14 +443,14 @@ public function testStoreFork() ->assertSuccessful(); $tree = LabelTree::orderBy('id', 'desc')->first(); - $this->assertEquals('abc', $tree->name); - $this->assertEquals('my description', $tree->description); + $this->assertSame('abc', $tree->name); + $this->assertSame('my description', $tree->description); $this->assertTrue($tree->members()->where('id', $this->guest()->id)->exists()); $parent = $tree->labels()->where('name', $baseParent->name)->first(); $this->assertNotNull($parent); $child = $tree->labels()->where('name', $baseChild->name)->first(); $this->assertNotNull($child); - $this->assertEquals($parent->id, $child->parent_id); + $this->assertSame($parent->id, $child->parent_id); } public function testDestroy() diff --git a/tests/php/Http/Controllers/Api/LabelTreeLabelControllerTest.php b/tests/php/Http/Controllers/Api/LabelTreeLabelControllerTest.php index 9bda666c7..6021b742d 100644 --- a/tests/php/Http/Controllers/Api/LabelTreeLabelControllerTest.php +++ b/tests/php/Http/Controllers/Api/LabelTreeLabelControllerTest.php @@ -60,7 +60,7 @@ public function testStoreNormal() // parent id must be integer $response->assertStatus(422); - $this->assertEquals(1, $tree->labels()->count()); + $this->assertSame(1, $tree->labels()->count()); $this->assertFalse($parent->children()->exists()); $response = $this->json('POST', "/api/v1/label-trees/{$tree->id}/labels", [ 'name' => 'new label', @@ -68,7 +68,7 @@ public function testStoreNormal() 'parent_id' => $parent->id, ]); $response->assertStatus(200); - $this->assertEquals(2, $tree->labels()->count()); + $this->assertSame(2, $tree->labels()->count()); $this->assertTrue($parent->children()->exists()); $response = $this->json('POST', "/api/v1/label-trees/{$tree->id}/labels", [ @@ -76,7 +76,7 @@ public function testStoreNormal() 'color' => 'bada55', ]); $response->assertStatus(200); - $this->assertEquals(3, $tree->labels()->count()); + $this->assertSame(3, $tree->labels()->count()); $label = $tree->labels()->where('name', 'new label 2')->first(); @@ -102,7 +102,7 @@ public function testStoreFormRequest() 'name' => 'new label', 'color' => 'bada55', ]); - $this->assertEquals(1, $tree->labels()->count()); + $this->assertSame(1, $tree->labels()->count()); $response->assertRedirect('/'); $response->assertSessionHas('saved', true); @@ -111,7 +111,7 @@ public function testStoreFormRequest() 'color' => 'bada55', '_redirect' => 'settings', ]); - $this->assertEquals(2, $tree->labels()->count()); + $this->assertSame(2, $tree->labels()->count()); $response->assertRedirect('/settings'); $response->assertSessionHas('saved', true); } diff --git a/tests/php/Http/Controllers/Api/LabelTreeUserControllerTest.php b/tests/php/Http/Controllers/Api/LabelTreeUserControllerTest.php index 3ef911552..f0888c396 100644 --- a/tests/php/Http/Controllers/Api/LabelTreeUserControllerTest.php +++ b/tests/php/Http/Controllers/Api/LabelTreeUserControllerTest.php @@ -36,18 +36,18 @@ public function testUpdate() // cannot update the own user $response->assertStatus(403); - $this->assertEquals(1, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); + $this->assertSame(1, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); $response = $this->json('PUT', "/api/v1/label-trees/{$t->id}/users/{$u->id}", [ 'role_id' => Role::adminId(), ]); $response->assertStatus(200); - $this->assertEquals(2, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); + $this->assertSame(2, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); $response = $this->json('PUT', "/api/v1/label-trees/{$t->id}/users/{$u->id}", [ 'role_id' => Role::editorId(), ]); $response->assertStatus(200); - $this->assertEquals(1, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); + $this->assertSame(1, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); } public function testUpdateGlobalGuest() @@ -74,7 +74,7 @@ public function testUpdateFormRequest() $response = $this->put("/api/v1/label-trees/{$t->id}/users/{$u->id}", [ 'role_id' => Role::adminId(), ]); - $this->assertEquals(2, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); + $this->assertSame(2, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); $response->assertRedirect('/'); $response->assertSessionHas('saved', true); @@ -82,7 +82,7 @@ public function testUpdateFormRequest() 'role_id' => Role::editorId(), '_redirect' => 'settings', ]); - $this->assertEquals(1, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); + $this->assertSame(1, $t->members()->where('label_tree_user.role_id', Role::adminId())->count()); $response->assertRedirect('/settings'); $response->assertSessionHas('saved', true); } @@ -139,7 +139,7 @@ public function testStore() $response->assertStatus(200); $user = $tree->members()->find($this->user()->id); $this->assertNotNull($user); - $this->assertEquals(Role::editorId(), $user->role_id); + $this->assertSame(Role::editorId(), $user->role_id); } public function testStoreGlobalGuest() @@ -168,7 +168,7 @@ public function testStoreFormRequest() 'id' => $this->user()->id, 'role_id' => Role::editorId(), ]); - $this->assertEquals(2, $tree->members()->count()); + $this->assertSame(2, $tree->members()->count()); $response->assertRedirect('/'); $response->assertSessionHas('saved', true); @@ -177,7 +177,7 @@ public function testStoreFormRequest() 'role_id' => Role::editorId(), '_redirect' => 'settings', ]); - $this->assertEquals(3, $tree->members()->count()); + $this->assertSame(3, $tree->members()->count()); $response->assertRedirect('/settings'); $response->assertSessionHas('saved', true); } diff --git a/tests/php/Http/Controllers/Api/LabelTreeVersionControllerTest.php b/tests/php/Http/Controllers/Api/LabelTreeVersionControllerTest.php index 8b9cdb8ff..6ac6b884c 100644 --- a/tests/php/Http/Controllers/Api/LabelTreeVersionControllerTest.php +++ b/tests/php/Http/Controllers/Api/LabelTreeVersionControllerTest.php @@ -49,14 +49,14 @@ public function testStore() $version = $master->versions()->first(); $this->assertNotNull($version); - $this->assertEquals('v1.0', $version->name); - $this->assertEquals($master->id, $version->label_tree_id); + $this->assertSame('v1.0', $version->name); + $this->assertSame($master->id, $version->label_tree_id); $versionTree = LabelTree::where('version_id', $version->id)->first(); $this->assertNotNull($versionTree); - $this->assertEquals($master->name, $versionTree->name); - $this->assertEquals('First version.', $versionTree->description); - $this->assertEquals($master->visibility_id, $versionTree->visibility_id); + $this->assertSame($master->name, $versionTree->name); + $this->assertSame('First version.', $versionTree->description); + $this->assertSame($master->visibility_id, $versionTree->visibility_id); $this->assertNotEquals($master->uuid, $versionTree->uuid); $this->assertNotNull($versionTree->authorizedProjects()->find($this->project()->id)); @@ -66,7 +66,7 @@ public function testStore() $this->assertEquals($labels->pluck('name'), $versionLabels->pluck('name')); $this->assertEquals($labels->pluck('color'), $versionLabels->pluck('color')); $this->assertNotEquals($labels->pluck('uuid'), $versionLabels->pluck('uuid')); - $this->assertEquals($versionLabels[0]->parent_id, $versionLabels[1]->id); + $this->assertSame($versionLabels[0]->parent_id, $versionLabels[1]->id); $this->assertNull($versionLabels[1]->parent_id); } @@ -82,7 +82,7 @@ public function testStoreDoi() ]) ->assertStatus(200); $version = $master->versions()->first(); - $this->assertEquals('10.5281/zenodo.xxxxxxx', $version->doi); + $this->assertSame('10.5281/zenodo.xxxxxxx', $version->doi); } public function testStoreDoiEmpty() @@ -123,7 +123,7 @@ public function testUpdate() ]) ->assertStatus(200); - $this->assertEquals('10.5281/zenodo.xxxxxxx', $version->fresh()->doi); + $this->assertSame('10.5281/zenodo.xxxxxxx', $version->fresh()->doi); } public function testDestroy() diff --git a/tests/php/Http/Controllers/Api/LinkVideoAnnotationControllerTest.php b/tests/php/Http/Controllers/Api/LinkVideoAnnotationControllerTest.php index 70876df82..9828b7acf 100644 --- a/tests/php/Http/Controllers/Api/LinkVideoAnnotationControllerTest.php +++ b/tests/php/Http/Controllers/Api/LinkVideoAnnotationControllerTest.php @@ -75,7 +75,7 @@ public function testStoreValidation() ->assertStatus(200) ->assertJsonFragment(['id' => $a1->id]); - $this->assertEquals(1, $this->video->annotations()->count()); + $this->assertSame(1, $this->video->annotations()->count()); $this->assertNull($a2->fresh()); } @@ -169,8 +169,8 @@ public function testStoreBefore() ->assertStatus(200); $a1->refresh(); - $this->assertEquals([1.0, 2.0, null, 3.0, 4.0], $a1->frames); - $this->assertEquals([[30, 30], [40, 40], [], [10, 10], [20, 20]], $a1->points); + $this->assertSame([1, 2, null, 3, 4], $a1->frames); + $this->assertSame([[30, 30], [40, 40], [], [10, 10], [20, 20]], $a1->points); } public function testStoreAfter() @@ -197,8 +197,8 @@ public function testStoreAfter() ->assertStatus(200); $a1->refresh(); - $this->assertEquals([1.0, 2.0, null, 3.0, 4.0], $a1->frames); - $this->assertEquals([[10, 10], [20, 20], [], [30, 30], [40, 40]], $a1->points); + $this->assertSame([1, 2, null, 3, 4], $a1->frames); + $this->assertSame([[10, 10], [20, 20], [], [30, 30], [40, 40]], $a1->points); } public function testStoreMergeLabels() @@ -244,10 +244,10 @@ public function testStoreMergeLabels() ]) ->assertStatus(200); - $this->assertEquals(3, $a1->labels()->count()); + $this->assertSame(3, $a1->labels()->count()); $this->assertNotNull($l1->fresh()); - $this->assertEquals($a1->id, $l2->fresh()->annotation_id); - $this->assertEquals($a1->id, $l3->fresh()->annotation_id); + $this->assertSame($a1->id, $l2->fresh()->annotation_id); + $this->assertSame($a1->id, $l3->fresh()->annotation_id); $this->assertNull($l4->fresh()); } @@ -275,8 +275,8 @@ public function testStoreTouching() ->assertStatus(200); $a1->refresh(); - $this->assertEquals([1.0, 2.0, 3.0], $a1->frames); - $this->assertEquals([[10, 10], [20, 20], [40, 40]], $a1->points); + $this->assertSame([1, 2, 3], $a1->frames); + $this->assertSame([[10, 10], [20, 20], [40, 40]], $a1->points); } public function testStoreSingleFrameTouching() @@ -328,7 +328,7 @@ public function testStoreWholeFrame() ->assertStatus(200); $a1->refresh(); - $this->assertEquals([1.0, null, 2.0], $a1->frames); - $this->assertEquals([], $a1->points); + $this->assertSame([1, null, 2], $a1->frames); + $this->assertEmpty($a1->points); } } diff --git a/tests/php/Http/Controllers/Api/NotificationControllerTest.php b/tests/php/Http/Controllers/Api/NotificationControllerTest.php index e8310f3c0..96a800687 100644 --- a/tests/php/Http/Controllers/Api/NotificationControllerTest.php +++ b/tests/php/Http/Controllers/Api/NotificationControllerTest.php @@ -14,7 +14,7 @@ public function testUpdate() $user->notify(new InAppNotification('test', 'test')); $notification = $user->notifications()->first(); $this->doTestApiRoute('PUT', '/api/v1/notifications/'.$notification->id); - $this->assertEquals(1, $user->unreadNotifications()->count()); + $this->assertSame(1, $user->unreadNotifications()->count()); $this->be(UserTest::create()); $response = $this->put('/api/v1/notifications/'.$notification->id) @@ -23,7 +23,7 @@ public function testUpdate() $this->be($user); $response = $this->put('/api/v1/notifications/'.$notification->id) ->assertStatus(200); - $this->assertEquals(0, $user->unreadNotifications()->count()); + $this->assertSame(0, $user->unreadNotifications()->count()); // only unread notifications can be marked as read $response = $this->put('/api/v1/notifications/'.$notification->id) @@ -36,7 +36,7 @@ public function testDestroy() $user->notify(new InAppNotification('test', 'test')); $notification = $user->notifications()->first(); $this->doTestApiRoute('DELETE', '/api/v1/notifications/'.$notification->id); - $this->assertEquals(1, $user->notifications()->count()); + $this->assertSame(1, $user->notifications()->count()); $this->be(UserTest::create()); $response = $this->delete('/api/v1/notifications/'.$notification->id) @@ -45,7 +45,7 @@ public function testDestroy() $this->be($user); $response = $this->delete('/api/v1/notifications/'.$notification->id) ->assertStatus(200); - $this->assertEquals(0, $user->notifications()->count()); + $this->assertSame(0, $user->notifications()->count()); } public function testUpdateAll() @@ -58,8 +58,8 @@ public function testUpdateAll() $this->doTestApiRoute('PUT', '/api/v1/notifications/all'); $this->be($user); - $this->assertEquals(3, $user->unreadNotifications()->count()); + $this->assertSame(3, $user->unreadNotifications()->count()); $this->put('/api/v1/notifications/all')->assertSuccessful(); - $this->assertEquals(0, $user->unreadNotifications()->count()); + $this->assertSame(0, $user->unreadNotifications()->count()); } } diff --git a/tests/php/Http/Controllers/Api/ProjectControllerTest.php b/tests/php/Http/Controllers/Api/ProjectControllerTest.php index 6ae047f8b..7e4277a8a 100644 --- a/tests/php/Http/Controllers/Api/ProjectControllerTest.php +++ b/tests/php/Http/Controllers/Api/ProjectControllerTest.php @@ -88,8 +88,8 @@ public function testUpdate() $response->assertStatus(200); $project = $this->project()->fresh(); - $this->assertEquals('my test', $project->name); - $this->assertEquals('this is my test', $project->description); + $this->assertSame('my test', $project->name); + $this->assertSame('this is my test', $project->description); $this->assertNotEquals(0, $project->creator_id); } @@ -102,7 +102,7 @@ public function testStore() $response = $this->json('POST', '/api/v1/projects'); $response->assertStatus(422); - $this->assertEquals(1, Project::count()); + $this->assertSame(1, Project::count()); $response = $this->json('POST', '/api/v1/projects', [ 'name' => 'test project', @@ -114,7 +114,7 @@ public function testStore() $this->assertStringStartsWith('{', $content); $this->assertStringEndsWith('}', $content); $this->assertStringContainsString('"name":"test project"', $content); - $this->assertEquals(2, Project::count()); + $this->assertSame(2, Project::count()); } public function testStoreAuthorization() diff --git a/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php b/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php index b654083f6..26cb79838 100644 --- a/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php +++ b/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php @@ -38,15 +38,15 @@ public function testStore() 'expires_at' => $timestamp, ]) ->assertSuccessful(); - + $invitation = $this->project()->invitations()->first(); $this->assertNotNull($invitation); - $this->assertEquals($timestamp, $invitation->expires_at); - $this->assertEquals(0, $invitation->current_uses); + $this->assertSame($timestamp->toDateTimeString(), $invitation->expires_at->tz($timestamp->timezone)->toDateTimeString()); + $this->assertSame(0, $invitation->current_uses); $this->assertNotNull($invitation->uuid); $this->assertNull($invitation->max_uses); $this->assertFalse($invitation->add_to_sessions); - $this->assertEquals(Role::editorId(), $invitation->role_id); + $this->assertSame(Role::editorId(), $invitation->role_id); } public function testStoreOptionalAttributes() @@ -95,8 +95,8 @@ public function testStoreOptionalAttributes() $invitation = $this->project()->invitations()->first(); $this->assertNotNull($invitation); - $this->assertEquals(10, $invitation->max_uses); - $this->assertEquals(Role::editorId(), $invitation->role_id); + $this->assertSame(10, $invitation->max_uses); + $this->assertSame(Role::editorId(), $invitation->role_id); $this->assertTrue($invitation->add_to_sessions); } @@ -160,11 +160,11 @@ public function testJoin() ]) ->assertSuccessful(); - $this->assertEquals(0, $invitation->current_uses); + $this->assertSame(0, $invitation->current_uses); $projectUser = $this->project()->users()->find($this->user()->id); $this->assertNotNull($projectUser); - $this->assertEquals(Role::guestId(), $projectUser->project_role_id); - $this->assertEquals(1, $invitation->fresh()->current_uses); + $this->assertSame(Role::guestId(), $projectUser->project_role_id); + $this->assertSame(1, $invitation->fresh()->current_uses); } public function testJoinRedirect() @@ -232,7 +232,7 @@ public function testJoinAlreadyMember() ]) ->assertSuccessful(); - $this->assertEquals(0, $invitation->fresh()->current_uses); + $this->assertSame(0, $invitation->fresh()->current_uses); } public function testJoinAddToSessions() diff --git a/tests/php/Http/Controllers/Api/ProjectLabelTreeControllerTest.php b/tests/php/Http/Controllers/Api/ProjectLabelTreeControllerTest.php index bbbf06240..f52d2bed6 100644 --- a/tests/php/Http/Controllers/Api/ProjectLabelTreeControllerTest.php +++ b/tests/php/Http/Controllers/Api/ProjectLabelTreeControllerTest.php @@ -118,20 +118,20 @@ public function testStore() 'id' => $authorized->id, ]); $response->assertStatus(200); - $this->assertEquals($count + 1, $p->labelTrees()->count()); + $this->assertSame($count + 1, $p->labelTrees()->count()); $response = $this->json('POST', "/api/v1/projects/{$p->id}/label-trees", [ 'id' => $public->id, ]); $response->assertStatus(200); - $this->assertEquals($count + 2, $p->labelTrees()->count()); + $this->assertSame($count + 2, $p->labelTrees()->count()); // if the tree is already attached, ignore and respond with success $response = $this->json('POST', "/api/v1/projects/{$p->id}/label-trees", [ 'id' => $public->id, ]); $response->assertStatus(200); - $this->assertEquals($count + 2, $p->labelTrees()->count()); + $this->assertSame($count + 2, $p->labelTrees()->count()); } public function testStoreFormRequest() diff --git a/tests/php/Http/Controllers/Api/ProjectUserControllerTest.php b/tests/php/Http/Controllers/Api/ProjectUserControllerTest.php index 23924b080..ffc4cf2cc 100644 --- a/tests/php/Http/Controllers/Api/ProjectUserControllerTest.php +++ b/tests/php/Http/Controllers/Api/ProjectUserControllerTest.php @@ -74,14 +74,14 @@ public function testUpdate() ->assertStatus(422) ->assertJsonFragment(['The last admin of '.$this->project()->name.' cannot be removed. The admin status must be passed on to another user first.']); - $this->assertEquals(2, $this->project()->users()->find($this->editor()->id)->project_role_id); + $this->assertSame(2, $this->project()->users()->find($this->editor()->id)->project_role_id); $response = $this->put("/api/v1/projects/{$id}/users/".$this->editor()->id, [ 'project_role_id' => Role::guestId(), ]); $response->assertStatus(200); - $this->assertEquals(3, $this->project()->users()->find($this->editor()->id)->project_role_id); + $this->assertSame(3, $this->project()->users()->find($this->editor()->id)->project_role_id); } public function testUpdateGlobalGuest() @@ -144,8 +144,8 @@ public function testAttach() $response->assertStatus(200); $newUser = $this->project()->users()->find($id); - $this->assertEquals($id, $newUser->id); - $this->assertEquals(Role::editorId(), $newUser->project_role_id); + $this->assertSame($id, $newUser->id); + $this->assertSame(Role::editorId(), $newUser->project_role_id); } public function testAttachGlobalGuest() diff --git a/tests/php/Http/Controllers/Api/ProjectVolumeControllerTest.php b/tests/php/Http/Controllers/Api/ProjectVolumeControllerTest.php index 3881dcfd3..75ac8a3eb 100644 --- a/tests/php/Http/Controllers/Api/ProjectVolumeControllerTest.php +++ b/tests/php/Http/Controllers/Api/ProjectVolumeControllerTest.php @@ -154,7 +154,7 @@ public function testStoreImages() ]); $response->assertSuccessful(); $content = $response->getContent(); - $this->assertEquals($count + 1, $this->project()->volumes()->count()); + $this->assertSame($count + 1, $this->project()->volumes()->count()); $this->assertStringStartsWith('{', $content); $this->assertStringEndsWith('}', $content); @@ -193,7 +193,7 @@ public function testStoreHandle() ]) ->assertStatus(201); $volume = Volume::orderBy('id', 'desc')->first(); - $this->assertEquals('10.3389/fmars.2017.00083', $volume->handle); + $this->assertSame('10.3389/fmars.2017.00083', $volume->handle); // Some DOIs can contain multiple slashes. $this @@ -419,7 +419,7 @@ public function testStoreVideos() 'files' => '1.mp4, 2.mp4', ]); $response->assertSuccessful(); - $this->assertEquals($count + 1, $this->project()->volumes()->count()); + $this->assertSame($count + 1, $this->project()->volumes()->count()); $id = json_decode($response->getContent())->id; Queue::assertPushed(CreateNewImagesOrVideos::class, function ($job) use ($id) { diff --git a/tests/php/Http/Controllers/Api/SplitVideoAnnotationControllerTest.php b/tests/php/Http/Controllers/Api/SplitVideoAnnotationControllerTest.php index 401a73c9b..9cbfb46a5 100644 --- a/tests/php/Http/Controllers/Api/SplitVideoAnnotationControllerTest.php +++ b/tests/php/Http/Controllers/Api/SplitVideoAnnotationControllerTest.php @@ -69,11 +69,11 @@ public function testStore() ]) ->assertStatus(200); - $this->assertEquals(2, $this->video->annotations()->count()); + $this->assertSame(2, $this->video->annotations()->count()); $this->video->annotations->each(function ($annotation) use ($label) { $compare = $annotation->labels()->first(); - $this->assertEquals($label->label_id, $compare->label_id); - $this->assertEquals($label->user_id, $compare->user_id); + $this->assertSame($label->label_id, $compare->label_id); + $this->assertSame($label->user_id, $compare->user_id); }); } diff --git a/tests/php/Http/Controllers/Api/UserControllerTest.php b/tests/php/Http/Controllers/Api/UserControllerTest.php index 642ce3de5..5b4facb66 100644 --- a/tests/php/Http/Controllers/Api/UserControllerTest.php +++ b/tests/php/Http/Controllers/Api/UserControllerTest.php @@ -186,7 +186,7 @@ public function testUpdate() 'auth_password' => 'adminpassword', ]); $response->assertStatus(200); - $this->assertEquals('new@email.me', $this->guest()->fresh()->email); + $this->assertSame('new@email.me', $this->guest()->fresh()->email); $response = $this->json('PUT', '/api/v1/users/'.$this->guest()->id, [ 'role_id' => 999, @@ -208,7 +208,7 @@ public function testUpdate() // wrong password $response->assertStatus(422); - $this->assertEquals(Role::editorId(), $this->guest()->fresh()->role_id); + $this->assertSame(Role::editorId(), $this->guest()->fresh()->role_id); $response = $this->put('/api/v1/users/'.$this->guest()->id, [ 'role_id' => Role::adminId(), @@ -216,7 +216,7 @@ public function testUpdate() '_redirect' => 'settings/profile', ]); $response->assertRedirect('settings/profile'); - $this->assertEquals(Role::adminId(), $this->guest()->fresh()->role_id); + $this->assertSame(Role::adminId(), $this->guest()->fresh()->role_id); $this->get('/'); $response = $this->put('/api/v1/users/'.$this->guest()->id, [ @@ -227,8 +227,8 @@ public function testUpdate() ]); $response->assertRedirect('/'); - $this->assertEquals('jack', $this->guest()->fresh()->firstname); - $this->assertEquals('jackson', $this->guest()->fresh()->lastname); + $this->assertSame('jack', $this->guest()->fresh()->firstname); + $this->assertSame('jackson', $this->guest()->fresh()->lastname); $this->assertNotEquals('', $this->guest()->fresh()->password); } @@ -253,7 +253,7 @@ public function testUpdateEmailCaseInsensitive() 'auth_password' => 'adminpassword', ]); $response->assertStatus(200); - $this->assertEquals('test2@test.com', $this->guest()->fresh()->email); + $this->assertSame('test2@test.com', $this->guest()->fresh()->email); } public function testUpdateAffiliation() @@ -263,7 +263,7 @@ public function testUpdateAffiliation() $this->putJson("api/v1/users/{$user->id}", ['affiliation' => 'My Company']) ->assertStatus(200); - $this->assertEquals('My Company', $user->fresh()->affiliation); + $this->assertSame('My Company', $user->fresh()->affiliation); $this->putJson("api/v1/users/{$user->id}", ['affiliation' => '']) ->assertStatus(200); @@ -290,7 +290,7 @@ public function testUpdateRole() 'auth_password' => 'adminpassword', ]) ->assertStatus(200); - $this->assertEquals(Role::editorId(), $user->fresh()->role_id); + $this->assertSame(Role::editorId(), $user->fresh()->role_id); $this ->putJson("api/v1/users/{$user->id}", [ 'role_id' => Role::expertId(), @@ -303,7 +303,7 @@ public function testUpdateRole() 'auth_password' => 'adminpassword', ]) ->assertStatus(200); - $this->assertEquals(Role::adminId(), $user->fresh()->role_id); + $this->assertSame(Role::adminId(), $user->fresh()->role_id); } public function testUpdateCanReview() @@ -421,9 +421,9 @@ public function testUpdateOwn() $user = $this->guest()->fresh(); $this->assertTrue(Hash::check('newpassword', $user->password)); - $this->assertEquals('jack', $user->firstname); - $this->assertEquals('jackson', $user->lastname); - $this->assertEquals('new@email.me', $user->email); + $this->assertSame('jack', $user->firstname); + $this->assertSame('jackson', $user->lastname); + $this->assertSame('new@email.me', $user->email); } public function testUpdateOwnEmailCaseInsensitive() @@ -447,7 +447,7 @@ public function testUpdateOwnEmailCaseInsensitive() 'auth_password' => 'guest-password', ]); $response->assertStatus(200); - $this->assertEquals('test2@test.com', $this->guest()->fresh()->email); + $this->assertSame('test2@test.com', $this->guest()->fresh()->email); } public function testUpdateOwnAffiliation() @@ -456,7 +456,7 @@ public function testUpdateOwnAffiliation() $this->putJson('api/v1/users/my', ['affiliation' => 'My Company']) ->assertStatus(200); - $this->assertEquals('My Company', $this->guest()->fresh()->affiliation); + $this->assertSame('My Company', $this->guest()->fresh()->affiliation); $this->putJson('api/v1/users/my', ['affiliation' => '']) ->assertStatus(200); @@ -493,11 +493,11 @@ public function testStore() $response->assertSuccessful(); $newUser = User::find(User::max('id')); - $this->assertEquals('jack', $newUser->firstname); - $this->assertEquals('jackson', $newUser->lastname); - $this->assertEquals('new@email.me', $newUser->email); - $this->assertEquals('My Company', $newUser->affiliation); - $this->assertEquals(Role::editorId(), $newUser->role_id); + $this->assertSame('jack', $newUser->firstname); + $this->assertSame('jackson', $newUser->lastname); + $this->assertSame('new@email.me', $newUser->email); + $this->assertSame('My Company', $newUser->affiliation); + $this->assertSame(Role::editorId(), $newUser->role_id); $response = $this->json('POST', '/api/v1/users', [ 'password' => 'newpassword', @@ -552,7 +552,7 @@ public function testStoreUuid() ])->assertSuccessful(); $user = User::where('email', 'new2@email.me')->first(); - $this->assertEquals('c796ccec-c746-308f-8009-9f1f68e2aa62', $user->uuid); + $this->assertSame('c796ccec-c746-308f-8009-9f1f68e2aa62', $user->uuid); $this->json('POST', '/api/v1/users', [ 'password' => 'password', diff --git a/tests/php/Http/Controllers/Api/UserRegistrationControllerTest.php b/tests/php/Http/Controllers/Api/UserRegistrationControllerTest.php index f0d334ef3..06207df44 100644 --- a/tests/php/Http/Controllers/Api/UserRegistrationControllerTest.php +++ b/tests/php/Http/Controllers/Api/UserRegistrationControllerTest.php @@ -25,7 +25,7 @@ public function testAcceptRegistration() $this->beGlobalReviewer(); $this->getJson("/api/v1/accept-user-registration/{$user->id}") ->assertStatus(200); - $this->assertEquals(Role::editorId(), $user->fresh()->role_id); + $this->assertSame(Role::editorId(), $user->fresh()->role_id); $this->getJson("/api/v1/accept-user-registration/{$user->id}") ->assertStatus(404); diff --git a/tests/php/Http/Controllers/Api/UserSettingsControllerTest.php b/tests/php/Http/Controllers/Api/UserSettingsControllerTest.php index 0f571da40..4aa889364 100644 --- a/tests/php/Http/Controllers/Api/UserSettingsControllerTest.php +++ b/tests/php/Http/Controllers/Api/UserSettingsControllerTest.php @@ -40,7 +40,7 @@ public function testUpdateAdditionalRules() $this->putJson("/api/v1/users/my/settings", ['test' => 123]) ->assertStatus(200); - $this->assertEquals(['test' => 123], $this->user()->fresh()->settings); + $this->assertSame(['test' => 123], $this->user()->fresh()->settings); } public function testUpdateIncludeFederatedSearch() diff --git a/tests/php/Http/Controllers/Api/VideoAnnotationControllerTest.php b/tests/php/Http/Controllers/Api/VideoAnnotationControllerTest.php index fb1ef1afa..69cba4f5f 100644 --- a/tests/php/Http/Controllers/Api/VideoAnnotationControllerTest.php +++ b/tests/php/Http/Controllers/Api/VideoAnnotationControllerTest.php @@ -287,9 +287,9 @@ public function testStore() $annotation = $this->video->annotations()->first(); $this->assertNotNull($annotation); - $this->assertEquals([[10, 11]], $annotation->points); - $this->assertEquals([0.0], $annotation->frames); - $this->assertEquals(1, $annotation->labels()->count()); + $this->assertSame([[10, 11]], $annotation->points); + $this->assertSame([0], $annotation->frames); + $this->assertSame(1, $annotation->labels()->count()); } public function testStoreValidatePoints() @@ -551,7 +551,7 @@ public function testStoreAndTrackIncrementRateLimit() ]) ->assertSuccessful(); - $this->assertEquals(1, Cache::get(TrackObject::getRateLimitCacheKey($this->editor()))); + $this->assertSame(1, Cache::get(TrackObject::getRateLimitCacheKey($this->editor()))); } public function testStoreAndTrackRestrictRateLimit() @@ -584,7 +584,7 @@ public function testTrackingJobLimit() 'track' => true, ])->assertSuccessful(); - $this->assertEquals(1, Cache::get(TrackObject::getRateLimitCacheKey($this->editor()))); + $this->assertSame(1, Cache::get(TrackObject::getRateLimitCacheKey($this->editor()))); $this->assertFalse($res->json()['trackingJobLimitReached']); Cache::set(TrackObject::getRateLimitCacheKey($this->editor()), 9); @@ -597,7 +597,7 @@ public function testTrackingJobLimit() 'track' => true, ])->assertSuccessful(); - $this->assertEquals(10, Cache::get(TrackObject::getRateLimitCacheKey($this->editor()))); + $this->assertSame(10, Cache::get(TrackObject::getRateLimitCacheKey($this->editor()))); $this->assertTrue($res->json()['trackingJobLimitReached']); } @@ -634,9 +634,9 @@ public function testStoreWholeFrameAnnotation() $annotation = $this->video->annotations()->first(); $this->assertNotNull($annotation); - $this->assertEquals([], $annotation->points); - $this->assertEquals([0.0, 1.5], $annotation->frames); - $this->assertEquals(1, $annotation->labels()->count()); + $this->assertEmpty($annotation->points); + $this->assertSame([0, 1.5], $annotation->frames); + $this->assertSame(1, $annotation->labels()->count()); } public function testStoreWholeFrameSingleFrameAnnotation() @@ -652,9 +652,9 @@ public function testStoreWholeFrameSingleFrameAnnotation() $annotation = $this->video->annotations()->first(); $this->assertNotNull($annotation); - $this->assertEquals([], $annotation->points); - $this->assertEquals([0.0], $annotation->frames); - $this->assertEquals(1, $annotation->labels()->count()); + $this->assertEmpty($annotation->points); + $this->assertSame([0], $annotation->frames); + $this->assertSame(1, $annotation->labels()->count()); } public function testStoreAndTrackWholeFrameAnnotation() @@ -723,8 +723,8 @@ public function testUpdate() ->assertStatus(200); $annotation = $annotation->fresh(); - $this->assertEquals([[10, 20], [30, 40]], $annotation->points); - $this->assertEquals([1.0, 10.0], $annotation->frames); + $this->assertSame([[10, 20], [30, 40]], $annotation->points); + $this->assertSame([1, 10], $annotation->frames); } public function testUpdateValidatePoints() @@ -785,7 +785,7 @@ public function testUpdateWholeFrameAnnotation() ->assertStatus(200); $annotation = $annotation->fresh(); - $this->assertEquals([1.0, 2.0, null, 3.0, 4.0], $annotation->frames); + $this->assertSame([1, 2, null, 3, 4], $annotation->frames); } public function testDestroy() diff --git a/tests/php/Http/Controllers/Api/VideoAnnotationLabelControllerTest.php b/tests/php/Http/Controllers/Api/VideoAnnotationLabelControllerTest.php index 353d7e04d..8f4aa797a 100644 --- a/tests/php/Http/Controllers/Api/VideoAnnotationLabelControllerTest.php +++ b/tests/php/Http/Controllers/Api/VideoAnnotationLabelControllerTest.php @@ -52,8 +52,8 @@ public function testStore() $label = $annotation->labels()->first(); $this->assertNotNull($label); - $this->assertEquals($this->labelRoot()->id, $label->label_id); - $this->assertEquals($this->editor()->id, $label->user_id); + $this->assertSame($this->labelRoot()->id, $label->label_id); + $this->assertSame($this->editor()->id, $label->user_id); Event::assertDispatched(AnnotationLabelAttached::class); $this diff --git a/tests/php/Http/Controllers/Api/VideoFileControllerTest.php b/tests/php/Http/Controllers/Api/VideoFileControllerTest.php index 9a19c9576..3232776da 100644 --- a/tests/php/Http/Controllers/Api/VideoFileControllerTest.php +++ b/tests/php/Http/Controllers/Api/VideoFileControllerTest.php @@ -69,9 +69,9 @@ public function testShowPartial() ->getJson("api/v1/videos/{$video->id}/file") ->assertStatus(206); - $this->assertEquals(6, $response->headers->get('Content-Length')); + $this->assertSame(6, intval($response->headers->get('Content-Length'))); $this->assertTrue($response->headers->has('Content-Range')); - $this->assertEquals('bytes 3-8/9', $response->headers->get('Content-Range')); + $this->assertSame('bytes 3-8/9', $response->headers->get('Content-Range')); } finally { $disk->deleteDirectory('files'); } diff --git a/tests/php/Http/Controllers/Api/VideoLabelControllerTest.php b/tests/php/Http/Controllers/Api/VideoLabelControllerTest.php index f54265fb9..bfd31dc52 100644 --- a/tests/php/Http/Controllers/Api/VideoLabelControllerTest.php +++ b/tests/php/Http/Controllers/Api/VideoLabelControllerTest.php @@ -53,7 +53,7 @@ public function testStore() $this ->postJson("/api/v1/videos/{$id}/labels")->assertStatus(422); - $this->assertEquals(0, $this->video->labels()->count()); + $this->assertSame(0, $this->video->labels()->count()); $this->beUser(); $this @@ -75,7 +75,7 @@ public function testStore() 'label_id' => $this->labelRoot()->id, ]) ->assertSuccessful(); - $this->assertEquals(1, $this->video->labels()->count()); + $this->assertSame(1, $this->video->labels()->count()); $this->beAdmin(); // the same label cannot be attached twice @@ -84,7 +84,7 @@ public function testStore() 'label_id' => $this->labelRoot()->id, ]) ->assertStatus(400); - $this->assertEquals(1, $this->video->labels()->count()); + $this->assertSame(1, $this->video->labels()->count()); $this ->postJson("/api/v1/videos/{$id}/labels", [ @@ -102,7 +102,7 @@ public function testStore() 'lastname' => $this->admin()->lastname, 'role_id' => $this->admin()->role_id, ]); - $this->assertEquals(2, $this->video->labels()->count()); + $this->assertSame(2, $this->video->labels()->count()); } public function testDestroy() diff --git a/tests/php/Http/Controllers/Api/VolumeAnnotationSessionControllerTest.php b/tests/php/Http/Controllers/Api/VolumeAnnotationSessionControllerTest.php index 0e732bb1f..0362be438 100644 --- a/tests/php/Http/Controllers/Api/VolumeAnnotationSessionControllerTest.php +++ b/tests/php/Http/Controllers/Api/VolumeAnnotationSessionControllerTest.php @@ -119,7 +119,7 @@ public function testStore() 'users' => [$this->admin()->id], ]); $response->assertSuccessful(); - $this->assertEquals(2, $this->volume()->annotationSessions()->count()); + $this->assertSame(2, $this->volume()->annotationSessions()->count()); $session = $this->volume()->annotationSessions() ->with('users') diff --git a/tests/php/Http/Controllers/Api/VolumeControllerTest.php b/tests/php/Http/Controllers/Api/VolumeControllerTest.php index 44c8cdc43..a65711e59 100644 --- a/tests/php/Http/Controllers/Api/VolumeControllerTest.php +++ b/tests/php/Http/Controllers/Api/VolumeControllerTest.php @@ -95,9 +95,9 @@ public function testUpdate() 'media_type_id' => MediaType::videoId(), ]); $response->assertStatus(200); - $this->assertEquals('the new volume', $this->volume()->fresh()->name); + $this->assertSame('the new volume', $this->volume()->fresh()->name); // Media type cannot be updated. - $this->assertEquals(MediaType::imageId(), $this->volume()->fresh()->media_type_id); + $this->assertSame(MediaType::imageId(), $this->volume()->fresh()->media_type_id); Queue::assertNothingPushed(); } @@ -120,7 +120,7 @@ public function testUpdateHandle() ]) ->assertStatus(200); $this->volume()->refresh(); - $this->assertEquals('10.3389/fmars.2017.00083', $this->volume()->handle); + $this->assertSame('10.3389/fmars.2017.00083', $this->volume()->handle); // Some DOIs can contain multiple slashes. $this @@ -169,7 +169,7 @@ public function testUpdateUrl() ]) ->assertStatus(200); - $this->assertEquals('editor-test://volumes', $this->volume()->fresh()->url); + $this->assertSame('editor-test://volumes', $this->volume()->fresh()->url); $this->beGlobalAdmin(); $this @@ -182,7 +182,7 @@ public function testUpdateUrl() 'url' => 'admin-test://volumes', ]) ->assertStatus(200); - $this->assertEquals('admin-test://volumes', $this->volume()->fresh()->url); + $this->assertSame('admin-test://volumes', $this->volume()->fresh()->url); Queue::assertPushed(ProcessNewVolumeFiles::class); } @@ -201,7 +201,7 @@ public function testUpdateInvalidUrl() 'url' => 'admin-test://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', ])->assertStatus(422); - $this->assertEquals('The url must not be greater than 256 characters.', $response->exception->getMessage()); + $this->assertSame('The url must not be greater than 256 characters.', $response->exception->getMessage()); Queue::assertNothingPushed(); } diff --git a/tests/php/Http/Controllers/Api/VolumeFileControllerTest.php b/tests/php/Http/Controllers/Api/VolumeFileControllerTest.php index 9a9fb31a7..851ce82b8 100644 --- a/tests/php/Http/Controllers/Api/VolumeFileControllerTest.php +++ b/tests/php/Http/Controllers/Api/VolumeFileControllerTest.php @@ -74,7 +74,7 @@ public function testStoreImage() $this->beAdmin(); $this->json('POST', "/api/v1/volumes/{$id}/files")->assertStatus(422); - $this->assertEquals(1, $this->volume()->images()->count()); + $this->assertSame(1, $this->volume()->images()->count()); $this ->json('POST', "/api/v1/volumes/{$id}/files", [ @@ -110,8 +110,8 @@ public function testStoreImage() $response->assertSimilarJson($images->toArray()); - $this->assertEquals(1, $images->where('filename', '1.jpg')->count()); - $this->assertEquals(1, $images->where('filename', '2.jpg')->count()); + $this->assertSame(1, $images->where('filename', '1.jpg')->count()); + $this->assertSame(1, $images->where('filename', '2.jpg')->count()); Queue::assertPushed(ProcessNewVolumeFiles::class); Event::assertDispatched('images.created'); } @@ -178,7 +178,7 @@ public function testStoreVideo() ])->id; VideoTest::create(['filename' => 'no.mp4', 'volume_id' => $id]); - $this->assertEquals(1, $this->volume()->videos()->count()); + $this->assertSame(1, $this->volume()->videos()->count()); $this->beAdmin(); @@ -216,8 +216,8 @@ public function testStoreVideo() $response->assertSimilarJson($files->toArray()); - $this->assertEquals(1, $files->where('filename', '1.mp4')->count()); - $this->assertEquals(1, $files->where('filename', '2.mp4')->count()); + $this->assertSame(1, $files->where('filename', '1.mp4')->count()); + $this->assertSame(1, $files->where('filename', '2.mp4')->count()); Queue::assertPushed(ProcessNewVolumeFiles::class); } diff --git a/tests/php/Http/Controllers/Api/Volumes/IfdoControllerTest.php b/tests/php/Http/Controllers/Api/Volumes/IfdoControllerTest.php index 861ffbe5c..f78817d5c 100644 --- a/tests/php/Http/Controllers/Api/Volumes/IfdoControllerTest.php +++ b/tests/php/Http/Controllers/Api/Volumes/IfdoControllerTest.php @@ -29,7 +29,7 @@ public function testGet() $response = $this->getJson("/api/v1/volumes/{$id}/ifdo"); $response->assertStatus(200); - $this->assertEquals("attachment; filename=biigle-volume-{$id}-ifdo.yaml", $response->headers->get('content-disposition')); + $this->assertSame("attachment; filename=biigle-volume-{$id}-ifdo.yaml", $response->headers->get('content-disposition')); } public function testDestroy() diff --git a/tests/php/Http/Controllers/Api/Volumes/MetadataControllerTest.php b/tests/php/Http/Controllers/Api/Volumes/MetadataControllerTest.php index 9237a93bf..df5209f34 100644 --- a/tests/php/Http/Controllers/Api/Volumes/MetadataControllerTest.php +++ b/tests/php/Http/Controllers/Api/Volumes/MetadataControllerTest.php @@ -60,15 +60,15 @@ public function testStoreImageMetadata() $png = $png->fresh(); $jpg = $jpg->fresh(); - $this->assertEquals('2016-12-19 12:27:00', $jpg->taken_at); - $this->assertEquals(52.220, $jpg->lng); - $this->assertEquals(28.123, $jpg->lat); - $this->assertEquals(-1500, $jpg->metadata['gps_altitude']); - $this->assertEquals(2.6, $jpg->metadata['area']); + $this->assertSame('2016-12-19 12:27:00', $jpg->taken_at->toDateTimeString()); + $this->assertSame(52.220, $jpg->lng); + $this->assertSame(28.123, $jpg->lat); + $this->assertSame(-1500, intval($jpg->metadata['gps_altitude'])); + $this->assertSame(2.6, floatval($jpg->metadata['area'])); // Import should update but not destroy existing metadata. - $this->assertEquals(10, $jpg->metadata['distance_to_ground']); - $this->assertEquals(4000, $jpg->metadata['water_depth']); - $this->assertEquals(180, $jpg->metadata['yaw']); + $this->assertSame(10, intval($jpg->metadata['distance_to_ground'])); + $this->assertSame(4000, $jpg->metadata['water_depth']); + $this->assertSame(180, intval($jpg->metadata['yaw'])); $this->assertNull($png->taken_at); $this->assertNull($png->lng); @@ -106,9 +106,9 @@ public function testStoreDeprecatedFileAttribute() ->assertSuccessful(); $image->refresh(); - $this->assertEquals(4000, $image->metadata['water_depth']); - $this->assertEquals(10, $image->metadata['distance_to_ground']); - $this->assertEquals(2.6, $image->metadata['area']); + $this->assertSame(4000, $image->metadata['water_depth']); + $this->assertSame(10, intval($image->metadata['distance_to_ground'])); + $this->assertSame(2.6, floatval($image->metadata['area'])); } public function testStoreImageMetadataText() @@ -130,9 +130,9 @@ public function testStoreImageMetadataText() ])->assertSuccessful(); $image->refresh(); - $this->assertEquals(4000, $image->metadata['water_depth']); - $this->assertEquals(10, $image->metadata['distance_to_ground']); - $this->assertEquals(2.5, $image->metadata['area']); + $this->assertSame(4000, $image->metadata['water_depth']); + $this->assertSame(10, intval($image->metadata['distance_to_ground'])); + $this->assertSame(2.5, floatval($image->metadata['area'])); } public function testStoreVideoMetadataCsv() diff --git a/tests/php/Http/Controllers/Auth/ControllerTest.php b/tests/php/Http/Controllers/Auth/ControllerTest.php index b35eaec64..c68fb79f5 100644 --- a/tests/php/Http/Controllers/Auth/ControllerTest.php +++ b/tests/php/Http/Controllers/Auth/ControllerTest.php @@ -70,7 +70,7 @@ public function testLoginSuccess() // login_at attribute should be set after login $this->assertNotNull($user->fresh()->login_at); - $this->assertEquals($user->id, Auth::user()->id); + $this->assertSame($user->id, Auth::user()->id); $response->assertRedirect('/'); } @@ -88,7 +88,7 @@ public function testLoginCaseInsensitive() 'password' => 'password', ]); - $this->assertEquals($user->id, Auth::user()->id); + $this->assertSame($user->id, Auth::user()->id); } public function testLogout() diff --git a/tests/php/Http/Controllers/Auth/RegisterControllerTest.php b/tests/php/Http/Controllers/Auth/RegisterControllerTest.php index c43b337f4..fea7a811e 100644 --- a/tests/php/Http/Controllers/Auth/RegisterControllerTest.php +++ b/tests/php/Http/Controllers/Auth/RegisterControllerTest.php @@ -63,10 +63,10 @@ public function testRegisterSuccess() $user = User::where('email', 'e@ma.il')->first(); $this->assertNotNull($user); - $this->assertEquals('a', $user->firstname); - $this->assertEquals('b', $user->lastname); - $this->assertEquals('something', $user->affiliation); - $this->assertEquals(Role::editorId(), $user->role_id); + $this->assertSame('a', $user->firstname); + $this->assertSame('b', $user->lastname); + $this->assertSame('something', $user->affiliation); + $this->assertSame(Role::editorId(), $user->role_id); } public function testRegisterHoneypot() @@ -103,7 +103,7 @@ public function testRegisterHoneypot() public function testRegisterEmailTaken() { UserTest::create(['email' => 'test@test.com']); - $this->assertEquals(1, User::count()); + $this->assertSame(1, User::count()); $response = $this->get('register'); $response = $this->post('register', [ @@ -114,13 +114,13 @@ public function testRegisterEmailTaken() 'lastname' => 'b', ])->assertRedirect('register'); - $this->assertEquals(1, User::count()); + $this->assertSame(1, User::count()); } public function testRegisterEmailTakenCaseInsensitive() { UserTest::create(['email' => 'test@test.com']); - $this->assertEquals(1, User::count()); + $this->assertSame(1, User::count()); $response = $this->get('register'); $response = $this->post('register', [ @@ -131,13 +131,13 @@ public function testRegisterEmailTakenCaseInsensitive() 'lastname' => 'b', ])->assertRedirect('register'); - $this->assertEquals(1, User::count()); + $this->assertSame(1, User::count()); } public function testRegisterWhenLoggedIn() { $this->be(UserTest::create()); - $this->assertEquals(1, User::count()); + $this->assertSame(1, User::count()); $this->get('register')->assertRedirect('/'); @@ -149,7 +149,7 @@ public function testRegisterWhenLoggedIn() 'lastname' => 'b', ])->assertRedirect('/'); - $this->assertEquals(1, User::count()); + $this->assertSame(1, User::count()); } public function testRegisterPrivacy() @@ -170,7 +170,7 @@ public function testRegisterPrivacy() 'homepage' => 'honeypotvalue', ])->assertRedirect('register'); - $this->assertEquals(0, User::count()); + $this->assertSame(0, User::count()); $response = $this->post('register', [ '_token' => Session::token(), @@ -183,7 +183,7 @@ public function testRegisterPrivacy() 'privacy' => '1', ])->assertRedirect('/'); - $this->assertEquals(1, User::count()); + $this->assertSame(1, User::count()); } public function testRegisterTerms() @@ -204,7 +204,7 @@ public function testRegisterTerms() 'homepage' => 'honeypotvalue', ])->assertRedirect('register'); - $this->assertEquals(0, User::count()); + $this->assertSame(0, User::count()); $response = $this->post('register', [ '_token' => Session::token(), @@ -217,7 +217,7 @@ public function testRegisterTerms() 'terms' => '1', ])->assertRedirect('/'); - $this->assertEquals(1, User::count()); + $this->assertSame(1, User::count()); } public function testRegisterAdminConfirmationDisabled() @@ -252,13 +252,13 @@ public function testRegisterAdminConfirmationEnabled() $user = User::where('email', 'e@ma.il')->first(); Notification::assertSentTo(new AnonymousNotifiable, RegistrationConfirmation::class, function ($notification) use ($user) { - $this->assertEquals($user->id, $notification->user->id); - $this->assertEquals($user->email, $notification->toMail(null)->replyTo[0][0]); + $this->assertSame($user->id, $notification->user->id); + $this->assertSame($user->email, $notification->toMail(null)->replyTo[0][0]); return true; }); $this->assertNotNull($user); - $this->assertEquals(Role::guestId(), $user->role_id); + $this->assertSame(Role::guestId(), $user->role_id); } public function testRegisterAdminConfirmationPossibleDuplicates() diff --git a/tests/php/ImageAnnotationTest.php b/tests/php/ImageAnnotationTest.php index 0c41b1ea4..23d3a137f 100644 --- a/tests/php/ImageAnnotationTest.php +++ b/tests/php/ImageAnnotationTest.php @@ -42,7 +42,7 @@ public function testCastPoints() $annotation = static::make(); $annotation->points = [1, 2, 3, 4]; $annotation->save(); - $this->assertEquals([1, 2, 3, 4], $annotation->fresh()->points); + $this->assertSame([1, 2, 3, 4], $annotation->fresh()->points); } public function testRoundPoints() @@ -50,7 +50,7 @@ public function testRoundPoints() $annotation = static::make(); $annotation->points = [1.23456789, 2.23456789, 3.1415]; $annotation->save(); - $this->assertEquals([1.23, 2.23, 3.14], $annotation->fresh()->points); + $this->assertSame([1.23, 2.23, 3.14], $annotation->fresh()->points); } public function testLabels() @@ -64,10 +64,10 @@ public function testLabels() 'confidence' => 0.5, ]); $this->modelLabel->save(); - $this->assertEquals(1, $this->model->labels()->count()); + $this->assertSame(1, $this->model->labels()->count()); $label = $this->model->labels()->first(); - $this->assertEquals(0.5, $label->confidence); - $this->assertEquals($user->id, $label->user->id); + $this->assertSame(0.5, $label->confidence); + $this->assertSame($user->id, $label->user->id); } public function testValidatePointsInteger() @@ -308,7 +308,7 @@ public function testScopeAllowedBySessionHideBoth() ]); $ids = ImageAnnotation::allowedBySession($session, $ownUser)->pluck('id')->toArray(); - $this->assertEquals([$a3->id], $ids); + $this->assertSame([$a3->id], $ids); } public function testScopeVisibleFor() @@ -335,18 +335,18 @@ public function testScopeWithLabel() $al1 = ImageAnnotationLabelTest::create(); $al2 = ImageAnnotationLabelTest::create(); - $this->assertEquals($al1->annotation->id, ImageAnnotation::withLabel($al1->label)->first()->id); + $this->assertSame($al1->annotation->id, ImageAnnotation::withLabel($al1->label)->first()->id); } public function testGetPoints() { $annotation = static::make(['points' => [1, 2]]); - $this->assertEquals([1, 2], $annotation->getPoints()); + $this->assertSame([1, 2], $annotation->getPoints()); } public function testGetShape() { - $this->assertEquals($this->model->shape, $this->model->getShape()); + $this->assertSame($this->model->shape, $this->model->getShape()); } public function testGetFile() @@ -356,6 +356,6 @@ public function testGetFile() public function testGetFileIdAttribute() { - $this->assertEquals($this->model->image_id, $this->model->file_id); + $this->assertSame($this->model->image_id, $this->model->file_id); } } diff --git a/tests/php/ImageTest.php b/tests/php/ImageTest.php index 286699e97..88dfc378a 100644 --- a/tests/php/ImageTest.php +++ b/tests/php/ImageTest.php @@ -33,7 +33,7 @@ public function testAttributes() public function testGetUrl() { - $this->assertEquals($this->model->url, $this->model->getUrl()); + $this->assertSame($this->model->url, $this->model->getUrl()); } public function testHiddenAttributes() @@ -75,7 +75,7 @@ public function testAnnotations() { $annotation = ImageAnnotationTest::create(['image_id' => $this->model->id]); ImageAnnotationTest::create(['image_id' => $this->model->id]); - $this->assertEquals(2, $this->model->annotations()->count()); + $this->assertSame(2, $this->model->annotations()->count()); $this->assertNotNull($this->model->annotations()->find($annotation->id)); } @@ -84,9 +84,9 @@ public function testGetFile() $this->model->mimetype = 'image/jpeg'; $this->model->size = 123; $response = $this->model->getFile(); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('image/jpeg', $response->headers->get('content-type')); - $this->assertEquals(123, $response->headers->get('content-length')); + $this->assertSame(200, $response->getStatusCode()); + $this->assertSame('image/jpeg', $response->headers->get('content-type')); + $this->assertSame(123, intval($response->headers->get('content-length'))); } public function testGetFileNotFound() @@ -102,7 +102,7 @@ public function testGetFileRemote() { $this->model->volume->url = 'http://localhost'; $response = $this->model->getFile(); - $this->assertEquals($this->model->url, $response->getTargetUrl()); + $this->assertSame($this->model->url, $response->getTargetUrl()); } public function testGetFileTiled() @@ -146,7 +146,7 @@ public function testGetFileTempUrl() Storage::shouldReceive('disk')->andReturn($mock); $response = $this->model->getFile(); - $this->assertEquals('https://example.com', $response->getTargetUrl()); + $this->assertSame('https://example.com', $response->getTargetUrl()); } public function testGetFileDiskNotFound() @@ -176,16 +176,16 @@ public function testTiledImagesDeletedEventOnDelete() public function testLabels() { $il = ImageLabelTest::create(['image_id' => $this->model->id]); - $this->assertEquals(1, $this->model->labels()->count()); + $this->assertSame(1, $this->model->labels()->count()); $label = $this->model->labels()->first(); - $this->assertEquals($il->id, $label->id); + $this->assertSame($il->id, $label->id); } public function testCastsAttrs() { $this->model->attrs = ['a', 'b', 'c']; $this->model->save(); - $this->assertEquals(['a', 'b', 'c'], $this->model->fresh()->attrs); + $this->assertSame(['a', 'b', 'c'], $this->model->fresh()->attrs); } public function testTakenAt() @@ -193,7 +193,7 @@ public function testTakenAt() $now = Carbon::now(); $this->model->taken_at = $now; $this->model->save(); - $this->assertEquals($now->timestamp, $this->model->fresh()->taken_at->timestamp); + $this->assertSame($now->timestamp, $this->model->fresh()->taken_at->timestamp); } public function testLatLng() @@ -202,8 +202,8 @@ public function testLatLng() $this->model->lng = 44.4; $this->model->save(); $this->model = $this->model->fresh(); - $this->assertEquals(55.5, $this->model->lat); - $this->assertEquals(44.4, $this->model->lng); + $this->assertSame(55.5, $this->model->lat); + $this->assertSame(44.4, $this->model->lng); } public function testTiledDefaultFalse() @@ -216,10 +216,10 @@ public function testTiledDefaultFalse() public function testSetGetMetadataAttribute() { - $this->assertEquals([], $this->model->metadata); + $this->assertSame([], $this->model->metadata); $this->model->metadata = ['water_depth' => 4000]; $this->model->save(); - $this->assertEquals(['water_depth' => 4000], $this->model->fresh()->metadata); + $this->assertSame(['water_depth' => 4000], $this->model->fresh()->metadata); } public function testSetGetWidthHeight() @@ -228,8 +228,8 @@ public function testSetGetWidthHeight() $this->model->height = 375; $this->model->save(); $this->model->refresh(); - $this->assertEquals(500, $this->model->width); - $this->assertEquals(375, $this->model->height); + $this->assertSame(500, $this->model->width); + $this->assertSame(375, $this->model->height); } public function testSetGetSize() @@ -237,7 +237,7 @@ public function testSetGetSize() $this->model->size = 12345; $this->model->save(); $this->model->refresh(); - $this->assertEquals(12345, $this->model->size); + $this->assertSame(12345, $this->model->size); } public function testSetGetMimetype() @@ -245,7 +245,7 @@ public function testSetGetMimetype() $this->model->mimetype = 'image/jpeg'; $this->model->save(); $this->model->refresh(); - $this->assertEquals('image/jpeg', $this->model->mimetype); + $this->assertSame('image/jpeg', $this->model->mimetype); } public function testSetGetTilingInProgress() diff --git a/tests/php/Jobs/CloneImagesOrVideosTest.php b/tests/php/Jobs/CloneImagesOrVideosTest.php index 907b34ee3..499676f1c 100644 --- a/tests/php/Jobs/CloneImagesOrVideosTest.php +++ b/tests/php/Jobs/CloneImagesOrVideosTest.php @@ -69,7 +69,7 @@ public function testCloneImageVolume() $this->assertFalse($copy->creating_async); $ignore = ['id', 'created_at', 'updated_at']; - $this->assertEquals( + $this->assertSame( $volume->makeHidden($ignore)->toArray(), $copy->makeHidden($ignore)->toArray() ); @@ -151,21 +151,21 @@ public function testCloneVolumeImages() $this->assertNotNull($newImageLabel); $this->assertNotNull($newImage); - $this->assertEquals($volume->images()->count(), $copy->images()->count()); + $this->assertSame($volume->images()->count(), $copy->images()->count()); $this->assertNotEquals($oldImage->id, $newImage->id); $this->assertNotEquals($oldImage->uuid, $newImage->uuid); - $this->assertEquals($copy->id, $newImage->volume_id); + $this->assertSame($copy->id, $newImage->volume_id); $this->assertNotEquals($oldImageLabel->id, $newImageLabel->id); $this->assertNotEquals($oldImageLabel->image_id, $newImageLabel->image_id); $ignore = ['id', 'volume_id', 'uuid']; - $this->assertEquals( + $this->assertSame( $oldImage->makeHidden($ignore)->toArray(), $newImage->makeHidden($ignore)->toArray(), ); $ignore = ['id', 'image_id']; - $this->assertEquals( + $this->assertSame( $oldImageLabel->makeHidden($ignore)->toArray(), $newImageLabel->makeHidden($ignore)->toArray(), ); @@ -213,7 +213,7 @@ public function testCloneVolumeImagesWithSomeLabels() $newImage = $copy->images()->first(); $newImageLabel = $newImage->labels()->get(); - $this->assertEquals(2, $newImageLabel->count()); + $this->assertSame(2, $newImageLabel->count()); $this->assertContains($l2->label_id, $newImageLabel->pluck('label_id')); $this->assertContains($l3->label_id, $newImageLabel->pluck('label_id')); } @@ -259,10 +259,10 @@ public function testCloneVolumeVideos() $this->assertNotNull($newVideo); $this->assertNotNull($newVideoLabel); - $this->assertEquals($volume->videos()->count(), $copy->videos()->count()); + $this->assertSame($volume->videos()->count(), $copy->videos()->count()); $this->assertNotEquals($oldVideo->id, $newVideo->id); $this->assertNotEquals($oldVideo->uuid, $newVideo->uuid); - $this->assertEquals($copy->id, $newVideo->volume_id); + $this->assertSame($copy->id, $newVideo->volume_id); $this->assertNotEquals($oldVideoLabel->id, $newVideoLabel->id); $this->assertNotEquals($oldVideoLabel->video_id, $newVideoLabel->video_id); @@ -320,7 +320,7 @@ public function testCloneVolumeVideosWithSomeLabels() $newVideo = $copy->videos()->first(); $newVideoLabels = $newVideo->labels()->get(); - $this->assertEquals(2, $newVideoLabels->count()); + $this->assertSame(2, $newVideoLabels->count()); $this->assertContains($l2->label_id, $newVideoLabels->pluck('label_id')); $this->assertContains($l3->label_id, $newVideoLabels->pluck('label_id')); } @@ -365,9 +365,9 @@ public function testCloneVolumeImageAnnotations() $this->assertNotNull($newAnnotationLabel); $this->assertNotEquals($oldAnnotation->id, $newAnnotation->id); $this->assertNotEquals($oldAnnotation->image_id, $newAnnotation->image_id); - $this->assertEquals($newAnnotation->image_id, $newImage->id); + $this->assertSame($newAnnotation->image_id, $newImage->id); $this->assertNotEquals($oldAnnotationLabel->id, $newAnnotationLabel->id); - $this->assertEquals($newAnnotation->id, $newAnnotationLabel->annotation_id); + $this->assertSame($newAnnotation->id, $newAnnotationLabel->annotation_id); $ignore = ['id', 'image_id']; $this->assertEquals( @@ -417,7 +417,7 @@ public function testCloneVolumeImageAnnotationsWithSomeLabels() $newAnnotation = $newImage->annotations()->first(); $newAnnotationLabels = $newAnnotation->labels()->get(); - $this->assertEquals(2, $newAnnotationLabels->count()); + $this->assertSame(2, $newAnnotationLabels->count()); $this->assertContains($l2->label_id, $newAnnotationLabels->pluck('label_id')); $this->assertContains($l3->label_id, $newAnnotationLabels->pluck('label_id')); } @@ -487,9 +487,9 @@ public function testCloneVolumeVideoAnnotations() $this->assertNotNull($newAnnotationLabel); $this->assertNotEquals($oldAnnotation->id, $newAnnotation->id); $this->assertNotEquals($oldAnnotation->video_id, $newAnnotation->video_id); - $this->assertEquals($newVideo->id, $newAnnotation->video_id); + $this->assertSame($newVideo->id, $newAnnotation->video_id); $this->assertNotEquals($oldAnnotationLabel->id, $newAnnotationLabel->id); - $this->assertEquals($newAnnotation->id, $newAnnotationLabel->annotation_id); + $this->assertSame($newAnnotation->id, $newAnnotationLabel->annotation_id); $ignore = ['id', 'video_id']; $this->assertEquals( @@ -540,7 +540,7 @@ public function testCloneVolumeVideoAnnotationsWithSomeLabels() $newAnnotation = $newVideo->annotations()->first(); $newAnnotationLabels = $newAnnotation->labels()->get(); - $this->assertEquals(2, $newAnnotationLabels->count()); + $this->assertSame(2, $newAnnotationLabels->count()); $this->assertContains($l2->label_id, $newAnnotationLabels->pluck('label_id')); $this->assertContains($l3->label_id, $newAnnotationLabels->pluck('label_id')); } @@ -602,7 +602,7 @@ public function testCloneVolumeIfDoFiles() $this->assertNotNull($copy->getIfdo()); $this->assertTrue($copy->hasIfdo()); - $this->assertEquals($volume->getIfdo(), $copy->getIfdo()); + $this->assertSame($volume->getIfdo(), $copy->getIfdo()); } public function testHandleVolumeImages() diff --git a/tests/php/Jobs/CreateNewImagesOrVideosTest.php b/tests/php/Jobs/CreateNewImagesOrVideosTest.php index 06044f071..6dce211e1 100644 --- a/tests/php/Jobs/CreateNewImagesOrVideosTest.php +++ b/tests/php/Jobs/CreateNewImagesOrVideosTest.php @@ -74,13 +74,13 @@ public function testHandleImageMetadata() with(new CreateNewImagesOrVideos($volume, $filenames, $metadata))->handle(); $image = $volume->images()->first(); - $this->assertEquals('2016-12-19 12:27:00', $image->taken_at); - $this->assertEquals(52.220, $image->lng); - $this->assertEquals(28.123, $image->lat); - $this->assertEquals(-1500, $image->metadata['gps_altitude']); - $this->assertEquals(2.6, $image->metadata['area']); - $this->assertEquals(10, $image->metadata['distance_to_ground']); - $this->assertEquals(180, $image->metadata['yaw']); + $this->assertSame('2016-12-19 12:27:00', $image->taken_at->toDateTimeString()); + $this->assertSame(52.220, $image->lng); + $this->assertSame(28.123, $image->lat); + $this->assertSame(-1500, intval($image->metadata['gps_altitude'])); + $this->assertSame(2.6, floatval($image->metadata['area'])); + $this->assertSame(10, intval($image->metadata['distance_to_ground'])); + $this->assertSame(180, intval($image->metadata['yaw'])); } public function testHandleImageMetadataEmptyCells() @@ -96,8 +96,8 @@ public function testHandleImageMetadataEmptyCells() with(new CreateNewImagesOrVideos($volume, $filenames, $metadata))->handle(); $image = $volume->images()->first(); - $this->assertEquals(52.220, $image->lng); - $this->assertEquals(28.123, $image->lat); + $this->assertSame(52.220, $image->lng); + $this->assertSame(28.123, $image->lat); $this->assertEmpty($image->metadata); } @@ -113,7 +113,7 @@ public function testHandleImageMetadataIncomplete() ]; with(new CreateNewImagesOrVideos($volume, $filenames, $metadata))->handle(); - $this->assertEquals(2, $volume->images()->count()); + $this->assertSame(2, $volume->images()->count()); } public function testHandleVideoMetadata() @@ -136,12 +136,12 @@ public function testHandleVideoMetadata() Carbon::parse('2016-12-19 12:28:00'), ]; $this->assertEquals($expect, $video->taken_at); - $this->assertEquals([52.220, 52.230], $video->lng); - $this->assertEquals([28.123, 28.133], $video->lat); - $this->assertEquals([-1500, -1505], $video->metadata['gps_altitude']); - $this->assertEquals([2.6, 1.6], $video->metadata['area']); - $this->assertEquals([10, 5], $video->metadata['distance_to_ground']); - $this->assertEquals([180, 181], $video->metadata['yaw']); + $this->assertSame([52.220, 52.230], $video->lng); + $this->assertSame([28.123, 28.133], $video->lat); + $this->assertSame([-1500, -1505], $video->metadata['gps_altitude']); + $this->assertSame([2.6, 1.6], $video->metadata['area']); + $this->assertSame([10, 5], $video->metadata['distance_to_ground']); + $this->assertSame([180, 181], $video->metadata['yaw']); } public function testHandleVideoMetadataEmptyCells() @@ -227,7 +227,7 @@ public function testHandleVideoMetadataIncomplete() ]; with(new CreateNewImagesOrVideos($volume, $filenames, $metadata))->handle(); - $this->assertEquals(2, $volume->videos()->count()); + $this->assertSame(2, $volume->videos()->count()); } public function testHandleMetadataDateParsing() @@ -243,6 +243,6 @@ public function testHandleMetadataDateParsing() with(new CreateNewImagesOrVideos($volume, $filenames, $metadata))->handle(); $image = $volume->images()->first(); - $this->assertEquals('2019-05-01 10:35:00', $image->taken_at); + $this->assertSame('2019-05-01 10:35:00', $image->taken_at->toDateTimeString()); } } diff --git a/tests/php/Jobs/GenerateFederatedSearchIndexTest.php b/tests/php/Jobs/GenerateFederatedSearchIndexTest.php index 3df954463..2fbf63813 100644 --- a/tests/php/Jobs/GenerateFederatedSearchIndexTest.php +++ b/tests/php/Jobs/GenerateFederatedSearchIndexTest.php @@ -25,7 +25,7 @@ public function testHandle() ]; $index = Cache::get(config('biigle.federated_search.cache_key')); - $this->assertEquals($expect, $index); + $this->assertSame($expect, $index); } public function testHandleLabelTree() @@ -54,7 +54,7 @@ public function testHandleLabelTree() ]; $index = Cache::get(config('biigle.federated_search.cache_key')); $this->assertEquals($expectTrees, $index['label_trees']); - $this->assertEquals($expectUsers, $index['users']); + $this->assertSame($expectUsers, $index['users']); } public function testHandleLabelTreeVersion() @@ -66,7 +66,7 @@ public function testHandleLabelTreeVersion() (new GenerateFederatedSearchIndex)->handle(); $index = Cache::get(config('biigle.federated_search.cache_key')); $this->assertCount(1, $index['label_trees']); - $this->assertEquals($version->label_tree_id, $index['label_trees'][0]['id']); + $this->assertSame($version->label_tree_id, $index['label_trees'][0]['id']); } public function testHandleLabelTreeGlobal() @@ -104,7 +104,7 @@ public function testHandleProject() ]; $index = Cache::get(config('biigle.federated_search.cache_key')); $this->assertEquals($expectProjects, $index['projects']); - $this->assertEquals($expectUsers, $index['users']); + $this->assertSame($expectUsers, $index['users']); } public function testHandleProjectLabelTrees() @@ -117,7 +117,7 @@ public function testHandleProjectLabelTrees() $project->labelTrees()->attach($tree); (new GenerateFederatedSearchIndex)->handle(); $index = Cache::get(config('biigle.federated_search.cache_key')); - $this->assertEquals([$tree->id], $index['projects'][0]['label_trees']); + $this->assertSame([$tree->id], $index['projects'][0]['label_trees']); } public function testHandleProjectVolumes() @@ -127,7 +127,7 @@ public function testHandleProjectVolumes() $project->volumes()->attach($volume); (new GenerateFederatedSearchIndex)->handle(); $index = Cache::get(config('biigle.federated_search.cache_key')); - $this->assertEquals([$volume->id], $index['projects'][0]['volumes']); + $this->assertSame([$volume->id], $index['projects'][0]['volumes']); } public function testHandleVolume() @@ -166,6 +166,6 @@ public function testHandleUsers() ]; $index = Cache::get(config('biigle.federated_search.cache_key')); - $this->assertEquals($expect, $index['users']); + $this->assertSame($expect, $index['users']); } } diff --git a/tests/php/Jobs/ProcessNewImageTest.php b/tests/php/Jobs/ProcessNewImageTest.php index bc7a34c54..5184f515f 100644 --- a/tests/php/Jobs/ProcessNewImageTest.php +++ b/tests/php/Jobs/ProcessNewImageTest.php @@ -34,14 +34,14 @@ public function testHandleCollectMetadata() $image = $image->fresh(); - $this->assertEquals('2011-12-31 17:07:29', (string) $image->taken_at); + $this->assertSame('2011-12-31 17:07:29', (string) $image->taken_at); $this->assertEqualsWithDelta(12.486211944, $image->lng, 0.000001); $this->assertEqualsWithDelta(41.8898575, $image->lat, 0.000001); - $this->assertEquals(56.819, $image->metadata['gps_altitude']); - $this->assertEquals(500, $image->width); - $this->assertEquals(375, $image->height); - $this->assertEquals(62411, $image->size); - $this->assertEquals('image/jpeg', $image->mimetype); + $this->assertSame(56.819, $image->metadata['gps_altitude']); + $this->assertSame(500, $image->width); + $this->assertSame(375, $image->height); + $this->assertSame(62411, $image->size); + $this->assertSame('image/jpeg', $image->mimetype); $this->assertTrue($volume->hasGeoInfo()); } @@ -58,7 +58,7 @@ public function testHandleCollectMetadataZeroDate() $job->exif = ['DateTimeOriginal' => '0000-00-00 00:00:00']; $job->handle(); $image = $image->fresh(); - $this->assertEquals(null, $image->taken_at); + $this->assertSame(null, $image->taken_at); } public function testHandleCollectMetadataAreaYaw() @@ -76,8 +76,8 @@ public function testHandleCollectMetadataAreaYaw() $job->handle(); $image = $image->fresh(); - $this->assertEquals(47.75, $image->metadata['yaw']); - $this->assertEquals(2.6, $image->metadata['area']); + $this->assertSame(47.75, floatval($image->metadata['yaw'])); + $this->assertSame(2.6, floatval($image->metadata['area'])); } public function testHandleMakeThumbnail() @@ -209,7 +209,7 @@ public function testHandleMergeMetadata() 'distance_to_ground' => 5, 'gps_altitude' => 500, ]; - $this->assertEquals($expect, $image->metadata); + $this->assertSame($expect, $image->metadata); } } diff --git a/tests/php/Jobs/ProcessNewVideoTest.php b/tests/php/Jobs/ProcessNewVideoTest.php index 1262b85ea..a6869dacd 100644 --- a/tests/php/Jobs/ProcessNewVideoTest.php +++ b/tests/php/Jobs/ProcessNewVideoTest.php @@ -21,8 +21,8 @@ public function testHandleThumbnails() $job->duration = 10; $job->handle(); - $this->assertEquals(10, $video->fresh()->duration); - $this->assertEquals([0.5, 5, 9.5], $job->times); + $this->assertSame(10, intval($video->fresh()->duration)); + $this->assertSame([0.5, 5.0, 9.5], $job->times); $disk = Storage::disk('video-thumbs'); $fragment = fragment_uuid_path($video->uuid); @@ -40,7 +40,7 @@ public function testHandleNotFound() $job->handle(); $this->fail('Expected an exception.'); } catch (Exception $e) { - $this->assertEquals(Video::ERROR_NOT_FOUND, $video->fresh()->error); + $this->assertSame(Video::ERROR_NOT_FOUND, $video->fresh()->error); } } @@ -55,7 +55,7 @@ public function testHandleTooLarge() $job->handle(); $this->fail('Expected an exception.'); } catch (Exception $e) { - $this->assertEquals(Video::ERROR_TOO_LARGE, $video->fresh()->error); + $this->assertSame(Video::ERROR_TOO_LARGE, $video->fresh()->error); } } @@ -64,7 +64,7 @@ public function testHandleMimeType() $video = VideoTest::create(['filename' => 'test.mp4']); $job = new ProcessNewVideoStub($video); $job->handle(); - $this->assertEquals('video/mp4', $video->fresh()->mimeType); + $this->assertSame('video/mp4', $video->fresh()->mimeType); } public function testHandleInvalidMimeType() @@ -72,8 +72,8 @@ public function testHandleInvalidMimeType() $video = VideoTest::create(['filename' => 'test-image.jpg']); $job = new ProcessNewVideoStub($video); $job->handle(); - $this->assertEquals('image/jpeg', $video->fresh()->mimeType); - $this->assertEquals(Video::ERROR_MIME_TYPE, $video->fresh()->error); + $this->assertSame('image/jpeg', $video->fresh()->mimeType); + $this->assertSame(Video::ERROR_MIME_TYPE, $video->fresh()->error); } public function testHandleInvalidMimeTypeFileCache() @@ -87,7 +87,7 @@ public function testHandleInvalidMimeTypeFileCache() $job->handle(); $this->fail('Expected an exception.'); } catch (Exception $e) { - $this->assertEquals(Video::ERROR_MIME_TYPE, $video->fresh()->error); + $this->assertSame(Video::ERROR_MIME_TYPE, $video->fresh()->error); } } @@ -96,7 +96,7 @@ public function testHandleSize() $video = VideoTest::create(['filename' => 'test.mp4']); $job = new ProcessNewVideoStub($video); $job->handle(); - $this->assertEquals(104500, $video->fresh()->size); + $this->assertSame(104500, $video->fresh()->size); } public function testHandleDimensions() @@ -104,8 +104,8 @@ public function testHandleDimensions() $video = VideoTest::create(['filename' => 'test.mp4']); $job = new ProcessNewVideoStub($video); $job->handle(); - $this->assertEquals(120, $video->fresh()->width); - $this->assertEquals(144, $video->fresh()->height); + $this->assertSame(120, $video->fresh()->width); + $this->assertSame(144, $video->fresh()->height); } public function testHandleMalformed() @@ -113,7 +113,7 @@ public function testHandleMalformed() $video = VideoTest::create(['filename' => 'test_malformed.mp4']); $job = new ProcessNewVideoStub($video); $job->handle(); - $this->assertEquals(Video::ERROR_MALFORMED, $video->fresh()->error); + $this->assertSame(Video::ERROR_MALFORMED, $video->fresh()->error); } public function testHandleInvalidCodec() @@ -122,7 +122,7 @@ public function testHandleInvalidCodec() $job = new ProcessNewVideoStub($video); $job->codec = 'h265'; $job->handle(); - $this->assertEquals(Video::ERROR_CODEC, $video->fresh()->error); + $this->assertSame(Video::ERROR_CODEC, $video->fresh()->error); } public function testHandleKeepErrorOnError() @@ -136,7 +136,7 @@ public function testHandleKeepErrorOnError() $job->handle(); $this->fail('Expected an exception.'); } catch (Exception $e) { - $this->assertEquals(Video::ERROR_MALFORMED, $video->fresh()->error); + $this->assertSame(Video::ERROR_MALFORMED, $video->fresh()->error); } } diff --git a/tests/php/Jobs/TileSingleImageTest.php b/tests/php/Jobs/TileSingleImageTest.php index 7eed98310..ace04048a 100644 --- a/tests/php/Jobs/TileSingleImageTest.php +++ b/tests/php/Jobs/TileSingleImageTest.php @@ -55,7 +55,7 @@ public function testQueue() config(['image.tiles.queue' => 'myqueue']); $image = ImageTest::create(); $job = new TileSingleImageStub($image); - $this->assertEquals('myqueue', $job->queue); + $this->assertSame('myqueue', $job->queue); } } diff --git a/tests/php/Jobs/TrackObjectTest.php b/tests/php/Jobs/TrackObjectTest.php index 4e1237cad..902e6d002 100644 --- a/tests/php/Jobs/TrackObjectTest.php +++ b/tests/php/Jobs/TrackObjectTest.php @@ -41,10 +41,10 @@ public function testHandle() $job = new TrackObjectStub($annotation, $user); $job->handle(); - $this->assertEquals(2, count($job->files)); + $this->assertSame(2, count($job->files)); $input = json_decode($job->files[0], true); - $this->assertEquals(0.5, $input['start_time']); - $this->assertEquals(123, $input['keyframe_distance']); + $this->assertSame(0.5, $input['start_time']); + $this->assertSame(123, $input['keyframe_distance']); $this->assertArrayHasKey('video_path', $input); foreach ($job->paths as $path) { @@ -89,7 +89,7 @@ public function testHandleCacheKeyMany() $job = new TrackObjectStub($annotation, $user); $job->handle(); - $this->assertEquals(1, Cache::get(TrackObjectStub::getRateLimitCacheKey($user))); + $this->assertSame(1, Cache::get(TrackObjectStub::getRateLimitCacheKey($user))); } public function testHandlePoint() @@ -109,17 +109,17 @@ public function testHandlePoint() $job->handle(); Event::assertDispatched(function (ObjectTrackingSucceeded $event) use ($annotation, $user) { - $this->assertEquals($user->id, $event->user->id); - $this->assertEquals($annotation->id, $event->annotation->id); + $this->assertSame($user->id, $event->user->id); + $this->assertSame($annotation->id, $event->annotation->id); return true; }); - $this->assertEquals([0.5, 1.0, 2.0, 3.0], $annotation->fresh()->frames); + $this->assertSame([0.5, 1, 2, 3], $annotation->fresh()->frames); $expect = [[0, 0], [10, 10], [20, 20], [30, 30]]; - $this->assertEquals($expect, $annotation->fresh()->points); + $this->assertSame($expect, $annotation->fresh()->points); $input = json_decode($job->files[0], true); - $this->assertEquals([-15, -15, 30, 30], $input['start_window']); + $this->assertSame([-15, -15, 30, 30], $input['start_window']); } public function testHandleCirlce() @@ -137,17 +137,17 @@ public function testHandleCirlce() $job->handle(); Event::assertDispatched(function (ObjectTrackingSucceeded $event) use ($annotation, $user) { - $this->assertEquals($user->id, $event->user->id); - $this->assertEquals($annotation->id, $event->annotation->id); + $this->assertSame($user->id, $event->user->id); + $this->assertSame($annotation->id, $event->annotation->id); return true; }); - $this->assertEquals([0.5, 1.0, 2.0, 3.0], $annotation->fresh()->frames); + $this->assertSame([0.5, 1, 2, 3], $annotation->fresh()->frames); $expect = [[10, 10, 5], [10, 10, 5], [20, 20, 6], [30, 30, 7]]; - $this->assertEquals($expect, $annotation->fresh()->points); + $this->assertSame($expect, $annotation->fresh()->points); $input = json_decode($job->files[0], true); - $this->assertEquals([5, 5, 10, 10], $input['start_window']); + $this->assertSame([5, 5, 10, 10], $input['start_window']); } public function testHandleFailure() @@ -164,14 +164,14 @@ public function testHandleFailure() $job->throw = true; $job->handle(); Event::assertDispatched(function (ObjectTrackingFailed $event) use ($annotation, $user) { - $this->assertEquals($user->id, $event->user->id); - $this->assertEquals($annotation->id, $event->annotation->id); + $this->assertSame($user->id, $event->user->id); + $this->assertSame($annotation->id, $event->annotation->id); return true; }); $annotation->refresh(); - $this->assertEquals([0.5], $annotation->frames); - $this->assertEquals([[10, 10]], $annotation->points); + $this->assertSame([0.5], $annotation->frames); + $this->assertSame([[10, 10]], $annotation->points); } public function testHandleEmpty() @@ -189,14 +189,14 @@ public function testHandleEmpty() $job->keyframes = '[]'; $job->handle(); Event::assertDispatched(function (ObjectTrackingFailed $event) use ($annotation, $user) { - $this->assertEquals($user->id, $event->user->id); - $this->assertEquals($annotation->id, $event->annotation->id); + $this->assertSame($user->id, $event->user->id); + $this->assertSame($annotation->id, $event->annotation->id); return true; }); $annotation->refresh(); - $this->assertEquals([0.5], $annotation->frames); - $this->assertEquals([[10, 10, 5]], $annotation->points); + $this->assertSame([0.5], $annotation->frames); + $this->assertSame([[10, 10, 5]], $annotation->points); } } diff --git a/tests/php/Jobs/UpdateFederatedSearchIndexTest.php b/tests/php/Jobs/UpdateFederatedSearchIndexTest.php index 902dd8f6c..fd5520e31 100644 --- a/tests/php/Jobs/UpdateFederatedSearchIndexTest.php +++ b/tests/php/Jobs/UpdateFederatedSearchIndexTest.php @@ -38,8 +38,8 @@ public function testHandleRequest() $this->assertCount(1, $container); $request = $container[0]['request']; - $this->assertEquals('https://example.com/api/v1/federated-search-index', strval($request->getUri())); - $this->assertEquals('Bearer my_token', $request->getHeaderLine('Authorization')); + $this->assertSame('https://example.com/api/v1/federated-search-index', strval($request->getUri())); + $this->assertSame('Bearer my_token', $request->getHeaderLine('Authorization')); $this->assertNotNull($instance->fresh()->indexed_at); } @@ -104,12 +104,12 @@ public function testHandleLabelTrees() $model = FederatedSearchModel::first(); $this->assertNotNull($model); - $this->assertEquals($labelTree['name'], $model->name); - $this->assertEquals($labelTree['description'], $model->description); - $this->assertEquals($labelTree['created_at'], $model->created_at); - $this->assertEquals($labelTree['updated_at'], $model->updated_at); - $this->assertEquals($instance->url.$labelTree['url'], $model->url); - $this->assertEquals(LabelTree::class, $model->type); + $this->assertSame($labelTree['name'], $model->name); + $this->assertSame($labelTree['description'], $model->description); + $this->assertSame($labelTree['created_at'], $model->created_at->toDateTimeString()); + $this->assertSame($labelTree['updated_at'], $model->updated_at->toDateTimeString()); + $this->assertSame($instance->url.$labelTree['url'], $model->url); + $this->assertSame(LabelTree::class, $model->type); $this->assertTrue($user->federatedSearchModels()->exists()); } @@ -153,13 +153,13 @@ public function testHandleProjects() $model = FederatedSearchModel::first(); $this->assertNotNull($model); - $this->assertEquals($project['name'], $model->name); - $this->assertEquals($project['description'], $model->description); - $this->assertEquals($project['created_at'], $model->created_at); - $this->assertEquals($project['updated_at'], $model->updated_at); - $this->assertEquals($instance->url.$project['url'], $model->url); - $this->assertEquals($project['thumbnail_url'], $model->thumbnailUrl); - $this->assertEquals(Project::class, $model->type); + $this->assertSame($project['name'], $model->name); + $this->assertSame($project['description'], $model->description); + $this->assertSame($project['created_at'], $model->created_at->toDateTimeString()); + $this->assertSame($project['updated_at'], $model->updated_at->toDateTimeString()); + $this->assertSame($instance->url.$project['url'], $model->url); + $this->assertSame($project['thumbnail_url'], $model->thumbnailUrl); + $this->assertSame(Project::class, $model->type); $this->assertTrue($user->federatedSearchModels()->projects()->exists()); } @@ -309,14 +309,14 @@ public function testHandleVolumes() $model = FederatedSearchModel::where('name', 'remote volume')->first(); $this->assertNotNull($model); - $this->assertEquals($volume['name'], $model->name); + $this->assertSame($volume['name'], $model->name); $this->assertNull($model->description); - $this->assertEquals($volume['created_at'], $model->created_at); - $this->assertEquals($volume['updated_at'], $model->updated_at); - $this->assertEquals($instance->url.$volume['url'], $model->url); - $this->assertEquals($volume['thumbnail_url'], $model->thumbnailUrl); - $this->assertEquals($volume['thumbnail_urls'], $model->thumbnailUrls->toArray()); - $this->assertEquals(Volume::class, $model->type); + $this->assertSame($volume['created_at'], $model->created_at->toDateTimeString()); + $this->assertSame($volume['updated_at'], $model->updated_at->toDateTimeString()); + $this->assertSame($instance->url.$volume['url'], $model->url); + $this->assertSame($volume['thumbnail_url'], $model->thumbnailUrl); + $this->assertSame($volume['thumbnail_urls'], $model->thumbnailUrls->toArray()); + $this->assertSame(Volume::class, $model->type); } public function testHandleCleanupDanglingModels() diff --git a/tests/php/LabelSourceTest.php b/tests/php/LabelSourceTest.php index 19f5e0289..e86dac58e 100644 --- a/tests/php/LabelSourceTest.php +++ b/tests/php/LabelSourceTest.php @@ -42,6 +42,6 @@ public function testGetAdapter() $source = self::create(['name' => 'ab_cd']); - $this->assertEquals($mock, $source->getAdapter()); + $this->assertSame($mock, $source->getAdapter()); } } diff --git a/tests/php/LabelTest.php b/tests/php/LabelTest.php index d01455cc2..1546fe9da 100644 --- a/tests/php/LabelTest.php +++ b/tests/php/LabelTest.php @@ -54,7 +54,7 @@ public function testParent() { $parent = self::create(); $child = self::create(['parent_id' => $parent->id]); - $this->assertEquals($parent->id, $child->parent->id); + $this->assertSame($parent->id, $child->parent->id); } public function testParentOnDeleteCascade() @@ -69,7 +69,7 @@ public function testTree() { $tree = LabelTreeTest::create(); $label = self::create(['label_tree_id' => $tree->id]); - $this->assertEquals($tree->id, $label->tree->id); + $this->assertSame($tree->id, $label->tree->id); } public function testLabelTreeOnDeleteCascade() @@ -84,14 +84,14 @@ public function testChildren() { $parent = self::create(); $child = self::create(['parent_id' => $parent->id]); - $this->assertEquals($child->id, $parent->children()->first()->id); + $this->assertSame($child->id, $parent->children()->first()->id); } public function testSetColorAttribute() { $label = self::create(); $label->color = '#aabbcc'; - $this->assertEquals('aabbcc', $label->color); + $this->assertSame('aabbcc', $label->color); } public function testIsUsedAnnotationLabel() diff --git a/tests/php/LabelTreeTest.php b/tests/php/LabelTreeTest.php index 976f1907d..ccfba4e15 100644 --- a/tests/php/LabelTreeTest.php +++ b/tests/php/LabelTreeTest.php @@ -116,7 +116,7 @@ public function testAddMember() { $this->assertFalse($this->model->members()->exists()); $this->model->addMember(UserTest::create(), Role::admin()); - $this->assertEquals(Role::adminId(), $this->model->members()->first()->role_id); + $this->assertSame(Role::adminId(), $this->model->members()->first()->role_id); } public function testAddMemberUserExists() @@ -143,9 +143,9 @@ public function testUpdateMember() { $user = UserTest::create(); $this->model->addMember($user, Role::editor()); - $this->assertEquals(Role::editorId(), $this->model->members()->first()->role_id); + $this->assertSame(Role::editorId(), $this->model->members()->first()->role_id); $this->model->updateMember($user, Role::admin()); - $this->assertEquals(Role::adminId(), $this->model->members()->first()->role_id); + $this->assertSame(Role::adminId(), $this->model->members()->first()->role_id); } public function testProjects() @@ -190,7 +190,7 @@ public function testDetachUnauthorizedProjects() // label trees without users are attached by default $tree->authorizedProjects()->attach($authorized->id); $tree->detachUnauthorizedProjects(); - $this->assertEquals([$authorized->id], array_map('intval', $tree->projects()->pluck('id')->all())); + $this->assertSame([$authorized->id], array_map('intval', $tree->projects()->pluck('id')->all())); } public function testDetachUnauthorizedProjectsPropagateToVersions() @@ -206,7 +206,7 @@ public function testDetachUnauthorizedProjectsPropagateToVersions() $version->labelTree->authorizedProjects()->attach($authorized->id); $this->model->authorizedProjects()->attach($authorized->id); $version->labelTree->detachUnauthorizedProjects(); - $this->assertEquals([$authorized->id], $this->model->projects()->pluck('id')->all()); + $this->assertSame([$authorized->id], $this->model->projects()->pluck('id')->all()); } public function testOrderLabelsByName() @@ -220,7 +220,7 @@ public function testOrderLabelsByName() 'name' => 'a', ]); - $this->assertEquals('a', $this->model->labels()->first()->name); + $this->assertSame('a', $this->model->labels()->first()->name); } public function testScopeAccessibleBy() @@ -232,18 +232,18 @@ public function testScopeAccessibleBy() $tree3 = self::create(['visibility_id' => Visibility::privateId()]); $ids = LabelTree::accessibleBy($user)->pluck('id')->toArray(); - $this->assertEquals([$tree->id], $ids); + $this->assertSame([$tree->id], $ids); $tree2->addMember($user, Role::editor()); $ids = LabelTree::accessibleBy($user)->pluck('id')->toArray(); - $this->assertEquals([$tree->id, $tree2->id], $ids); + $this->assertSame([$tree->id, $tree2->id], $ids); $project = ProjectTest::create(['creator_id' => $user->id]); $project->labelTrees()->attach($tree3); $ids = LabelTree::accessibleBy($user)->pluck('id')->toArray(); - $this->assertEquals([$tree->id, $tree2->id, $tree3->id], $ids); + $this->assertSame([$tree->id, $tree2->id, $tree3->id], $ids); } public function testScopeAccessibleByAdmin() @@ -265,9 +265,9 @@ public function testVersion() public function testVersions() { - $this->assertEquals(0, $this->model->versions()->count()); + $this->assertSame(0, $this->model->versions()->count()); $version = LabelTreeVersionTest::create(['label_tree_id' => $this->model->id]); - $this->assertEquals(1, $this->model->versions()->count()); + $this->assertSame(1, $this->model->versions()->count()); } public function testCascadeDeleteMaster() @@ -297,7 +297,7 @@ public function testScopeWithoutVersions() $version = LabelTreeVersionTest::create(); $this->model->version_id = $version->id; $this->model->save(); - $this->assertEquals([$version->label_tree_id], LabelTree::withoutVersions()->pluck('id')->all()); + $this->assertSame([$version->label_tree_id], LabelTree::withoutVersions()->pluck('id')->all()); } public function testScopeGlobal() @@ -307,7 +307,7 @@ public function testScopeGlobal() $this->model->save(); $ids = LabelTree::global()->pluck('id')->all(); - $this->assertEquals([$version->label_tree_id], $ids); + $this->assertSame([$version->label_tree_id], $ids); $version->labelTree->addMember(UserTest::create(), Role::adminId()); $this->assertFalse(LabelTree::global()->exists()); } @@ -322,8 +322,8 @@ public function testGetVersionedNameAttribute() $this->model->version_id = $version->id; $this->model->save(); - $this->assertEquals('master tree', $version->labelTree->versionedName); - $this->assertEquals('versioned tree @ v1.0', $this->model->versionedName); + $this->assertSame('master tree', $version->labelTree->versionedName); + $this->assertSame('versioned tree @ v1.0', $this->model->versionedName); } public function testReplicateLabelsOf() @@ -341,6 +341,6 @@ public function testReplicateLabelsOf() $this->assertNotNull($newParent); $newChild = $tree->labels()->where('name', $child->name)->first(); $this->assertNotNull($newChild); - $this->assertEquals($newParent->id, $newChild->parent_id); + $this->assertSame($newParent->id, $newChild->parent_id); } } diff --git a/tests/php/LabelTreeVersionTest.php b/tests/php/LabelTreeVersionTest.php index 1eae48da7..0fd1b9ad5 100644 --- a/tests/php/LabelTreeVersionTest.php +++ b/tests/php/LabelTreeVersionTest.php @@ -46,6 +46,6 @@ public function testDoiNullable() public function testNormalizeDoi() { $this->model->doi = 'https://doi.org/10.5281/zenodo.xxxxxxx'; - $this->assertEquals('10.5281/zenodo.xxxxxxx', $this->model->doi); + $this->assertSame('10.5281/zenodo.xxxxxxx', $this->model->doi); } } diff --git a/tests/php/ProjectTest.php b/tests/php/ProjectTest.php index 3261393ad..22785ffa6 100644 --- a/tests/php/ProjectTest.php +++ b/tests/php/ProjectTest.php @@ -52,19 +52,19 @@ public function testCreatorNullable() { $this->model->creator()->dissociate(); $this->model->save(); - $this->assertEquals(null, $this->model->creator_id); + $this->assertSame(null, $this->model->creator_id); } public function testCreatorOnDeleteSetNull() { $this->model->creator()->delete(); - $this->assertEquals(null, $this->model->fresh()->creator); + $this->assertSame(null, $this->model->fresh()->creator); } public function testCreator() { // creator will be user as well - $this->assertEquals($this->model->creator->id, $this->model->users()->first()->id); + $this->assertSame($this->model->creator->id, $this->model->users()->first()->id); } public function testUsers() @@ -84,8 +84,8 @@ public function testAdmins() // the creator doesn't count $this->model->creator->delete(); - $this->assertEquals(2, $this->model->users()->count()); - $this->assertEquals(1, $this->model->admins()->count()); + $this->assertSame(2, $this->model->users()->count()); + $this->assertSame(1, $this->model->admins()->count()); } public function testEditors() @@ -96,8 +96,8 @@ public function testEditors() $this->model->addUserId($member->id, Role::guestId()); // count the project creator, too - $this->assertEquals(3, $this->model->users()->count()); - $this->assertEquals(1, $this->model->editors()->count()); + $this->assertSame(3, $this->model->users()->count()); + $this->assertSame(1, $this->model->editors()->count()); } public function testGuests() @@ -106,16 +106,16 @@ public function testGuests() $this->model->addUserId($member->id, Role::guestId()); // count the project creator, too - $this->assertEquals(2, $this->model->users()->count()); - $this->assertEquals(1, $this->model->guests()->count()); + $this->assertSame(2, $this->model->users()->count()); + $this->assertSame(1, $this->model->guests()->count()); } public function testVolumes() { $volume = VolumeTest::make(); $this->model->volumes()->save($volume); - $this->assertEquals($volume->id, $this->model->volumes()->first()->id); - $this->assertEquals(1, $this->model->volumes()->count()); + $this->assertSame($volume->id, $this->model->volumes()->first()->id); + $this->assertSame(1, $this->model->volumes()->count()); } public function testAddUserId() @@ -126,7 +126,7 @@ public function testAddUserId() $this->model->addUserId($user->id, Role::editorId()); $user = $this->model->users()->find($user->id); $this->assertNotNull($user); - $this->assertEquals(Role::editorId(), $user->project_role_id); + $this->assertSame(Role::editorId(), $user->project_role_id); // a user can only be added once regardless the role $this->expectException(QueryException::class); @@ -155,9 +155,9 @@ public function testChangeRole() { $user = UserTest::create(); $this->model->addUserId($user->id, Role::adminId()); - $this->assertEquals(Role::adminId(), $this->model->users()->find($user->id)->project_role_id); + $this->assertSame(Role::adminId(), $this->model->users()->find($user->id)->project_role_id); $this->model->changeRole($user->id, Role::editorId()); - $this->assertEquals(Role::editorId(), $this->model->users()->find($user->id)->project_role_id); + $this->assertSame(Role::editorId(), $this->model->users()->find($user->id)->project_role_id); } public function testRemoveVolume() @@ -220,7 +220,7 @@ public function testLabelTrees() { $count = $this->model->labelTrees()->count(); LabelTreeTest::create()->projects()->attach($this->model->id); - $this->assertEquals($count + 1, $this->model->labelTrees()->count()); + $this->assertSame($count + 1, $this->model->labelTrees()->count()); } public function testAuthorizedLabelTrees() @@ -245,12 +245,12 @@ public function testDefaultLabelTreesWithoutVersions() $tree = LabelTreeTest::create(['version_id' => $version->id]); $project = self::create(); $ids = $project->labelTrees()->pluck('id')->all(); - $this->assertEquals([$version->labelTree->id], $ids); + $this->assertSame([$version->labelTree->id], $ids); } public function testGetThumbnailUrlAttributeNull() { - $this->assertEquals(null, $this->model->thumbnailUrl); + $this->assertSame(null, $this->model->thumbnailUrl); } public function testGetThumbnailUrlAttributeImage() @@ -298,8 +298,8 @@ public function testScopeInCommon() $p->volumes()->attach($v); $projects = Project::inCommon($user, $v->id)->pluck('id'); - $this->assertEquals(1, $projects->count()); - $this->assertEquals($this->model->id, $projects[0]); + $this->assertSame(1, $projects->count()); + $this->assertSame($this->model->id, $projects[0]); $projects = Project::inCommon($user, $v->id, [Role::adminId()])->pluck('id'); $this->assertEmpty($projects); @@ -309,20 +309,20 @@ public function testImageVolumes() { $v = VolumeTest::create(['media_type_id' => MediaType::videoId()]); $this->model->addVolumeId($v->id); - $this->assertEquals(0, $this->model->imageVolumes()->count()); + $this->assertSame(0, $this->model->imageVolumes()->count()); $v = VolumeTest::create(['media_type_id' => MediaType::imageId()]); $this->model->addVolumeId($v->id); - $this->assertEquals(1, $this->model->imageVolumes()->count()); + $this->assertSame(1, $this->model->imageVolumes()->count()); } public function testVideoVolumes() { $v = VolumeTest::create(['media_type_id' => MediaType::imageId()]); $this->model->addVolumeId($v->id); - $this->assertEquals(0, $this->model->videoVolumes()->count()); + $this->assertSame(0, $this->model->videoVolumes()->count()); $v = VolumeTest::create(['media_type_id' => MediaType::videoId()]); $this->model->addVolumeId($v->id); - $this->assertEquals(1, $this->model->videoVolumes()->count()); + $this->assertSame(1, $this->model->videoVolumes()->count()); } public function testScopeAccessibleBy() diff --git a/tests/php/ProjectUserIntegrityTest.php b/tests/php/ProjectUserIntegrityTest.php index 7200f503b..845c2aacb 100644 --- a/tests/php/ProjectUserIntegrityTest.php +++ b/tests/php/ProjectUserIntegrityTest.php @@ -23,9 +23,9 @@ public function testProjectOnDeleteCascade() $user = UserTest::create(); $project->addUserId($user->id, RoleTest::create()->id); - $this->assertEquals(1, $user->projects()->count()); + $this->assertSame(1, $user->projects()->count()); $project->delete(); - $this->assertEquals(0, $user->projects()->count()); + $this->assertSame(0, $user->projects()->count()); } public function testUserOnDeleteCascade() @@ -35,9 +35,9 @@ public function testUserOnDeleteCascade() $project->addUserId($member->id, Role::guestId()); // count the project creator, too - $this->assertEquals(2, $project->users()->count()); + $this->assertSame(2, $project->users()->count()); $member->delete(); - $this->assertEquals(1, $project->users()->count()); + $this->assertSame(1, $project->users()->count()); } public function testUserProjectRoleUnique() diff --git a/tests/php/ProjectVolumeIntegrityTest.php b/tests/php/ProjectVolumeIntegrityTest.php index 415b3766a..329d24821 100644 --- a/tests/php/ProjectVolumeIntegrityTest.php +++ b/tests/php/ProjectVolumeIntegrityTest.php @@ -12,9 +12,9 @@ public function testVolumeOnDeleteCascade() $project = ProjectTest::create(); $volume = VolumeTest::make(); $project->volumes()->save($volume); - $this->assertEquals(1, $project->volumes()->count()); + $this->assertSame(1, $project->volumes()->count()); $volume->delete(); - $this->assertEquals(0, $project->volumes()->count()); + $this->assertSame(0, $project->volumes()->count()); } public function testProjectOnDeleteRestrict() diff --git a/tests/php/RoleTest.php b/tests/php/RoleTest.php index 0512ae9a0..1f4ed7ced 100644 --- a/tests/php/RoleTest.php +++ b/tests/php/RoleTest.php @@ -43,25 +43,25 @@ public function testOnDeleteRestrict() public function testAdmin() { - $this->assertEquals('admin', Role::admin()->name); + $this->assertSame('admin', Role::admin()->name); $this->assertNotNull(Role::adminId()); } public function testExpert() { - $this->assertEquals('expert', Role::expert()->name); + $this->assertSame('expert', Role::expert()->name); $this->assertNotNull(Role::expertId()); } public function testEditor() { - $this->assertEquals('editor', Role::editor()->name); + $this->assertSame('editor', Role::editor()->name); $this->assertNotNull(Role::editorId()); } public function testGuest() { - $this->assertEquals('guest', Role::guest()->name); + $this->assertSame('guest', Role::guest()->name); $this->assertNotNull(Role::guestId()); } } diff --git a/tests/php/Rules/VolumeUrlTest.php b/tests/php/Rules/VolumeUrlTest.php index a47a3c412..a1a76e0bf 100644 --- a/tests/php/Rules/VolumeUrlTest.php +++ b/tests/php/Rules/VolumeUrlTest.php @@ -142,8 +142,8 @@ public function testRemoteOk() $this->assertTrue($validator->passes(null, 'http://localhost')); $request = $container[0]['request']; - $this->assertEquals('HEAD', $request->getMethod()); - $this->assertEquals('http://localhost', (string) $request->getUri()); + $this->assertSame('HEAD', $request->getMethod()); + $this->assertSame('http://localhost', (string) $request->getUri()); } public function testRemoteOfflineMode() diff --git a/tests/php/Services/Auth/ApiGuardTest.php b/tests/php/Services/Auth/ApiGuardTest.php index 17e2b316b..65465b284 100644 --- a/tests/php/Services/Auth/ApiGuardTest.php +++ b/tests/php/Services/Auth/ApiGuardTest.php @@ -120,7 +120,7 @@ public function testTouchToken() $token->updated_at = Carbon::now(-5); $token->save(); - $this->assertEquals($token->updated_at, $token->fresh()->updated_at); + $this->assertSame($token->updated_at->toDateTimeString(), $token->fresh()->updated_at->toDateTimeString()); $response = $this->call('GET', '/api/v1/users', [], [], [], [ 'PHP_AUTH_USER' => $token->owner->email, diff --git a/tests/php/Services/LabelSourceAdapters/WormsAdapterTest.php b/tests/php/Services/LabelSourceAdapters/WormsAdapterTest.php index 0b85eb891..4938f145c 100644 --- a/tests/php/Services/LabelSourceAdapters/WormsAdapterTest.php +++ b/tests/php/Services/LabelSourceAdapters/WormsAdapterTest.php @@ -88,7 +88,7 @@ public function testFind() ], ]]; - $this->assertEquals($expect, $results); + $this->assertSame($expect, $results); } public function testFindAccepted() @@ -117,7 +117,7 @@ public function testFindEmpty() $adapter->setSoapClient($mock); $request = new Request; $results = $adapter->find($request); - $this->assertEquals([], $results); + $this->assertSame([], $results); } public function testFindThrowException() @@ -138,7 +138,7 @@ public function testFindThrowException() $adapter->find($request); $this->assertFalse(true); } catch (ServiceUnavailableHttpException $e) { - $this->assertEquals('The WoRMS server is currently unavailable.', $e->getMessage()); + $this->assertSame('The WoRMS server is currently unavailable.', $e->getMessage()); } } @@ -175,7 +175,7 @@ public function testCreateNormal() $labels = $adapter->create($tree->id, $request); $this->assertTrue(false); } catch (ValidationException $e) { - $this->assertEquals(['source_id' => ['The AphiaID does not exist.']], $e->errors()); + $this->assertSame(['source_id' => ['The AphiaID does not exist.']], $e->errors()); } $request->merge([ @@ -184,12 +184,12 @@ public function testCreateNormal() $labels = $adapter->create($tree->id, $request); $this->assertTrue($tree->labels()->where('id', $labels[0]->id)->exists()); - $this->assertEquals('My Kolga', $labels[0]->name); - $this->assertEquals('bada55', $labels[0]->color); - $this->assertEquals('124731', $labels[0]->source_id); - $this->assertEquals(1, $labels[0]->label_source_id); - $this->assertEquals($label->id, $labels[0]->parent_id); - $this->assertEquals($tree->id, $labels[0]->label_tree_id); + $this->assertSame('My Kolga', $labels[0]->name); + $this->assertSame('bada55', $labels[0]->color); + $this->assertSame('124731', $labels[0]->source_id); + $this->assertSame(1, $labels[0]->label_source_id); + $this->assertSame($label->id, $labels[0]->parent_id); + $this->assertSame($tree->id, $labels[0]->label_tree_id); $this->assertNotNull($labels[0]->uuid); } @@ -213,7 +213,7 @@ public function testCreateThrowException() $adapter->create($tree->id, $request); $this->assertFalse(true); } catch (ServiceUnavailableHttpException $e) { - $this->assertEquals('The WoRMS server is currently unavailable.', $e->getMessage()); + $this->assertSame('The WoRMS server is currently unavailable.', $e->getMessage()); } } @@ -266,7 +266,7 @@ public function testCreateParentRecursiveError() $labels = $adapter->create(1, $request); $this->assertTrue(false); } catch (ValidationException $e) { - $this->assertEquals(['parent_id' => ['The label must not have a parent if it should be created recursively.']], $e->errors()); + $this->assertSame(['parent_id' => ['The label must not have a parent if it should be created recursively.']], $e->errors()); } } @@ -326,7 +326,7 @@ public function testCreateRecursive() $labels = $adapter->create($tree->id, $request); $this->assertCount(2, $labels); - $this->assertEquals(3, $tree->labels()->count()); + $this->assertSame(3, $tree->labels()->count()); $parent = $tree->labels()->where('source_id', 123514)->first(); $expect = [ diff --git a/tests/php/Services/ModulesTest.php b/tests/php/Services/ModulesTest.php index 386b67827..a2f2a76da 100644 --- a/tests/php/Services/ModulesTest.php +++ b/tests/php/Services/ModulesTest.php @@ -24,7 +24,7 @@ public function testGetControllerMixins() Modules::registerControllerMixin('myModule', 'dashboard', $func); $this->assertEmpty(Modules::getControllerMixins('nonexistent')); - $this->assertEquals(['myModule' => $func], Modules::getControllerMixins('dashboard')); + $this->assertSame(['myModule' => $func], Modules::getControllerMixins('dashboard')); } public function testRegister() @@ -41,7 +41,7 @@ public function testRegister() $this->assertArrayHasKey('myModule', Modules::getViewMixins('dashboard')); $this->assertArrayHasKey('myModule', Modules::getViewMixins('settings')); - $this->assertEquals(['myModule' => $func], Modules::getControllerMixins('dashboard')); + $this->assertSame(['myModule' => $func], Modules::getControllerMixins('dashboard')); $this->assertContains('my/path', Modules::getApidocPaths()); } @@ -49,7 +49,7 @@ public function testRegisterViewMixinOrdering() { Modules::registerViewMixin('subtest', 'index.test'); Modules::registerViewMixin('test', 'index'); - $this->assertEquals(['test' => ['subtest' => []]], Modules::getViewMixins('index')); + $this->assertSame(['test' => ['subtest' => []]], Modules::getViewMixins('index')); } public function testCallControllerMixins() @@ -58,7 +58,7 @@ public function testCallControllerMixins() Modules::registerControllerMixin('myModule2', 'dashboard', ControllerMixinStub::class.'@call'); $values = Modules::callControllerMixins('dashboard', ['arg' => 1]); - $this->assertEquals(['callable' => true, 'callableWithAtSign' => true], $values); + $this->assertSame(['callable' => true, 'callableWithAtSign' => true], $values); } } diff --git a/tests/php/Traits/ParsesMetadataTest.php b/tests/php/Traits/ParsesMetadataTest.php index ea3d08d20..ac6b89a08 100644 --- a/tests/php/Traits/ParsesMetadataTest.php +++ b/tests/php/Traits/ParsesMetadataTest.php @@ -17,7 +17,7 @@ public function testParseMetadataOk() ['filename', 'taken_at', 'lng', 'lat', 'gps_altitude', 'distance_to_ground', 'area', 'yaw'], ['abc.jpg', '2016-12-19 12:27:00', '52.220', '28.123', '-1500', '10', '2.6', '180'], ]; - $this->assertEquals($expect, $stub->parseMetadata($input)); + $this->assertSame($expect, $stub->parseMetadata($input)); } public function testParseMetadataCaseInsensitive() @@ -28,7 +28,7 @@ public function testParseMetadataCaseInsensitive() ['filename', 'taken_at', 'lng', 'lat', 'gps_altitude', 'distance_to_ground', 'area'], ['abc.jpg', '2016-12-19 12:27:00', '52.220', '28.123', '-1500', '10', '2.6'], ]; - $this->assertEquals($expect, $stub->parseMetadata($input)); + $this->assertSame($expect, $stub->parseMetadata($input)); } public function testParseMetadataSynonyms1() @@ -39,7 +39,7 @@ public function testParseMetadataSynonyms1() ['filename', 'lng', 'lat', 'yaw'], ['abc.jpg', '52.220', '28.123', '180'], ]; - $this->assertEquals($expect, $stub->parseMetadata($input)); + $this->assertSame($expect, $stub->parseMetadata($input)); } public function testParseMetadataSynonyms2() @@ -50,7 +50,7 @@ public function testParseMetadataSynonyms2() ['filename', 'lng', 'lat'], ['abc.jpg', '52.220', '28.123'], ]; - $this->assertEquals($expect, $stub->parseMetadata($input)); + $this->assertSame($expect, $stub->parseMetadata($input)); } public function testParseMetadataSynonyms3() @@ -61,7 +61,7 @@ public function testParseMetadataSynonyms3() ['filename', 'taken_at', 'lng', 'lat', 'gps_altitude', 'distance_to_ground', 'area', 'yaw'], ['abc.jpg', '2016-12-19 12:27:00', '52.220', '28.123', '-1500', '10', '2.6', '180'], ]; - $this->assertEquals($expect, $stub->parseMetadata($input)); + $this->assertSame($expect, $stub->parseMetadata($input)); } public function testParseMetadataEmptyCells() @@ -72,7 +72,7 @@ public function testParseMetadataEmptyCells() ['filename', 'taken_at', 'lng', 'lat', 'gps_altitude', 'distance_to_ground', 'area', 'yaw'], ['abc.jpg', '', '52.220', '28.123', '', '', '', ''], ]; - $this->assertEquals($expect, $stub->parseMetadata($input)); + $this->assertSame($expect, $stub->parseMetadata($input)); } public function testParseMetadataFile() @@ -84,7 +84,7 @@ public function testParseMetadataFile() ['filename', 'taken_at', 'lng', 'lat', 'gps_altitude', 'distance_to_ground', 'area', 'yaw'], ['abc.jpg', '2016-12-19 12:27:00', '52.220', '28.123', '-1500', '10', '2.6', '180'], ]; - $this->assertEquals($expect, $stub->parseMetadataFile($file)); + $this->assertSame($expect, $stub->parseMetadataFile($file)); } public function testParseMetadataFileBOM() @@ -96,7 +96,7 @@ public function testParseMetadataFileBOM() ['filename', 'taken_at', 'lng', 'lat', 'gps_altitude', 'distance_to_ground', 'area', 'yaw'], ['abc.jpg', '2016-12-19 12:27:00', '52.220', '28.123', '-1500', '10', '2.6', '180'], ]; - $this->assertEquals($expect, $stub->parseMetadataFile($file)); + $this->assertSame($expect, $stub->parseMetadataFile($file)); } public function testParseIfdo() @@ -112,16 +112,16 @@ public function testParseIfdo() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => '', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'image', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => '', + 'media_type' => 'image', 'files' => [ ['filename'], ['myimage.jpg'], ], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoHeader() @@ -146,16 +146,16 @@ public function testParseIfdoHeader() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => 'https://hdl.handle.net/20.500.12085/d7546c4b-307f-4d42-8554-33236c577450@data', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'image', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => 'https://hdl.handle.net/20.500.12085/d7546c4b-307f-4d42-8554-33236c577450@data', + 'media_type' => 'image', 'files' => [ ['filename', 'area', 'distance_to_ground', 'gps_altitude', 'lat', 'lng', 'taken_at', 'yaw'], - ['myimage.jpg', '5.0', '2', '-2248.0', '11.8581802', '-117.0214864', '2019-04-06 04:29:27.000000', '20'], + ['myimage.jpg', 5.0, 2, -2248.0, 11.8581802, -117.0214864, '2019-04-06 04:29:27.000000', 20], ], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoVideoType() @@ -172,16 +172,16 @@ public function testParseIfdoVideoType() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => '', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'video', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => '', + 'media_type' => 'video', 'files' => [ ['filename'], ['myvideo.mp4'], ], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoSlideIsImageType() @@ -198,16 +198,16 @@ public function testParseIfdoSlideIsImageType() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => '', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'image', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => '', + 'media_type' => 'image', 'files' => [ ['filename'], ['myimage.jpg'], ], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoItems() @@ -230,16 +230,16 @@ public function testParseIfdoItems() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => '', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'image', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => '', + 'media_type' => 'image', 'files' => [ ['filename', 'area', 'distance_to_ground', 'gps_altitude', 'lat', 'lng', 'taken_at', 'yaw'], - ['myimage.jpg', '5.0', '2', '-2248.0', '11.8581802', '-117.0214864', '2019-04-06 04:29:27.000000', '20'], + ['myimage.jpg', 5.0, 2, -2248.0, 11.8581802, -117.0214864, '2019-04-06 04:29:27.000000', 20], ], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoImageArrayItems() @@ -262,16 +262,17 @@ public function testParseIfdoImageArrayItems() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => '', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'image', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => '', + 'media_type' => 'image', 'files' => [ ['filename', 'area', 'distance_to_ground', 'gps_altitude', 'lat', 'lng', 'taken_at', 'yaw'], - ['myimage.jpg', '5.0', '2', '-2248.0', '11.8581802', '-117.0214864', '2019-04-06 04:29:27.000000', '20'], + ['myimage.jpg', 5.0, 2, -2248.0, 11.8581802, -117.0214864, '2019-04-06 04:29:27.000000', 20], + ], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoItemsOverrideHeader() @@ -297,16 +298,16 @@ public function testParseIfdoItemsOverrideHeader() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => '', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'image', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => '', + 'media_type' => 'image', 'files' => [ ['filename', 'area', 'distance_to_ground', 'gps_altitude', 'lat', 'lng', 'taken_at', 'yaw'], - ['myimage.jpg', '5.1', '3', '-2248.0', '11.8581802', '-117.0214864', '2019-04-06 05:29:27.000000', '20'], + ['myimage.jpg', 5.1, 3, -2248.0, 11.8581802, -117.0214864, '2019-04-06 05:29:27.000000', 20], ], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoSubItemsOverrideDefaultsAndHeader() @@ -335,17 +336,17 @@ public function testParseIfdoSubItemsOverrideDefaultsAndHeader() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => '', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'video', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => '', + 'media_type' => 'video', 'files' => [ ['filename', 'area', 'distance_to_ground', 'gps_altitude', 'lat', 'lng', 'taken_at', 'yaw'], - ['myvideo.mp4', '5.1', '3', '-2248.0', '11.8581802', '-117.0214864', '2019-04-06 05:29:27.000000', '20'], - ['myvideo.mp4', '5.1', '4', '-2248.0', '11.8581802', '-117.0214864', '2019-04-06 05:30:27.000000', '20'], + ['myvideo.mp4', 5.1, 3, -2248.0, 11.8581802, -117.0214864, '2019-04-06 05:29:27.000000', 20], + ['myvideo.mp4', 5.1, 4, -2248.0, 11.8581802, -117.0214864, '2019-04-06 05:30:27.000000', 20], ], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoFile() @@ -355,17 +356,17 @@ public function testParseIfdoFile() $file = new UploadedFile($path, 'ifdo.yaml', 'application/yaml', null, true); $expect = [ 'name' => 'SO268 SO268-2_100-1_OFOS SO_CAM-1_Photo_OFOS', - 'url' => 'https://hdl.handle.net/20.500.12085/d7546c4b-307f-4d42-8554-33236c577450@data', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'image', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => 'https://hdl.handle.net/20.500.12085/d7546c4b-307f-4d42-8554-33236c577450@data', + 'media_type' => 'image', 'files' => [ ['filename', 'area', 'distance_to_ground', 'gps_altitude', 'lat', 'lng', 'taken_at', 'yaw'], - ['SO268-2_100-1_OFOS_SO_CAM-1_20190406_042927.JPG', '5.0', '2', '-2248.0', '11.8581802', '-117.0214864', '2019-04-06 04:29:27.000000', '20'], - ['SO268-2_100-1_OFOS_SO_CAM-1_20190406_052726.JPG', '5.1', '2.1', '-4129.6', '11.8582192', '-117.0214286', '2019-04-06 05:27:26.000000', '21'], + ['SO268-2_100-1_OFOS_SO_CAM-1_20190406_042927.JPG', 5.0, 2, -2248.0, 11.8581802, -117.0214864, '2019-04-06 04:29:27.000000', 20], + ['SO268-2_100-1_OFOS_SO_CAM-1_20190406_052726.JPG', 5.1, 2.1, -4129.6, 11.8582192, -117.0214286, '2019-04-06 05:27:26.000000', 21], ], ]; - $this->assertEquals($expect, $stub->parseIfdoFile($file)); + $this->assertSame($expect, $stub->parseIfdoFile($file)); } public function testParseIfdoNoHeader() @@ -391,13 +392,13 @@ public function testParseIfdoNoItems() IFDO; $expect = [ 'name' => 'myvolume', - 'url' => '', 'handle' => '20.500.12085/d7546c4b-307f-4d42-8554-33236c577450', - 'media_type' => 'image', 'uuid' => 'd7546c4b-307f-4d42-8554-33236c577450', + 'url' => '', + 'media_type' => 'image', 'files' => [], ]; - $this->assertEquals($expect, $stub->parseIfdo($input)); + $this->assertSame($expect, $stub->parseIfdo($input)); } public function testParseIfdoNoName() diff --git a/tests/php/UserTest.php b/tests/php/UserTest.php index 5a8cd919a..5a0cae83f 100644 --- a/tests/php/UserTest.php +++ b/tests/php/UserTest.php @@ -32,7 +32,7 @@ public function testEmailToLowercase() { $this->model->email = 'Test@Example.com'; $this->model->save(); - $this->assertEquals('test@example.com', $this->model->fresh()->email); + $this->assertSame('test@example.com', $this->model->fresh()->email); } public function testCastsLoginAt() @@ -99,7 +99,7 @@ public function testProjects() $project->addUserId($this->model->id, $role->id); $p = $this->model->projects()->first(); - $this->assertEquals($project->id, $p->id); + $this->assertSame($project->id, $p->id); $this->assertFalse($p->pivot->pinned); } @@ -112,7 +112,7 @@ public function testLabelTrees() public function testRole() { - $this->assertEquals(Role::editorId(), $this->model->role->id); + $this->assertSame(Role::editorId(), $this->model->role->id); } public function testIsGlobalAdminAttribute() @@ -164,22 +164,22 @@ public function testCheckCanBeDeletedLabelTrees() public function testCastSettings() { $user = self::create(['attrs' => ['settings' => ['abc' => 'def']]]); - $this->assertEquals(['abc' => 'def'], $user->fresh()->settings); + $this->assertSame(['abc' => 'def'], $user->fresh()->settings); } public function testSetSettings() { $this->model->setSettings(['a' => true]); $this->model->save(); - $this->assertEquals(['a' => true], $this->model->fresh()->settings); + $this->assertSame(['a' => true], $this->model->fresh()->settings); $this->model->setSettings(['b' => 20]); $this->model->save(); - $this->assertEquals(['a' => true, 'b' => 20], $this->model->fresh()->settings); + $this->assertSame(['a' => true, 'b' => 20], $this->model->fresh()->settings); $this->model->setSettings(['a' => null, 'b' => 10]); $this->model->save(); - $this->assertEquals(['b' => 10], $this->model->fresh()->settings); + $this->assertSame(['b' => 10], $this->model->fresh()->settings); $this->model->setSettings(['a' => null, 'b' => null]); $this->model->save(); @@ -189,9 +189,9 @@ public function testSetSettings() public function testGetSettings() { $this->assertNull($this->model->getSettings('mysetting')); - $this->assertEquals('a', $this->model->getSettings('mysetting', 'a')); + $this->assertSame('a', $this->model->getSettings('mysetting', 'a')); $this->model->setSettings(['mysetting' => 'b']); - $this->assertEquals('b', $this->model->getSettings('mysetting', 'a')); + $this->assertSame('b', $this->model->getSettings('mysetting', 'a')); } public function testGetIsInSuperUserModeAttribute() diff --git a/tests/php/VideoAnnotationTest.php b/tests/php/VideoAnnotationTest.php index bbe480fdb..bbe32b037 100644 --- a/tests/php/VideoAnnotationTest.php +++ b/tests/php/VideoAnnotationTest.php @@ -38,7 +38,7 @@ public function testRoundPoints() { $this->model->points = [[1.23456789, 2.23456789, 3.1415]]; $this->model->save(); - $this->assertEquals([[1.23, 2.23, 3.14]], $this->model->fresh()->points); + $this->assertSame([[1.23, 2.23, 3.14]], $this->model->fresh()->points); } public function testValidatePointsFramesMismatch() @@ -139,7 +139,7 @@ public function testInterpolatePointsPoint() $this->model->shape_id = Shape::pointId(); $this->model->points = [[0, 0], [10, 10]]; $this->model->frames = [0.0, 1.0]; - $this->assertEquals([5, 5], $this->model->interpolatePoints(0.5)); + $this->assertSame([5.0, 5.0], $this->model->interpolatePoints(0.5)); } public function testInterpolatePointsInt() @@ -147,7 +147,7 @@ public function testInterpolatePointsInt() $this->model->shape_id = Shape::pointId(); $this->model->points = [[0, 0], [10, 10]]; $this->model->frames = [0, 1]; - $this->assertEquals([10, 10], $this->model->interpolatePoints(1)); + $this->assertSame([10, 10], $this->model->interpolatePoints(1)); } public function testInterpolatePointsRectangle() @@ -159,8 +159,8 @@ public function testInterpolatePointsRectangle() ]; $this->model->frames = [0.0, 1.0]; - $expect = [11.25, 5, 16.25, 10, 6.25, 20, 1.25, 15]; - $this->assertEquals($expect, $this->model->interpolatePoints(0.5)); + $expect = [11.25, 5.0, 16.25, 10.0, 6.25, 20.0, 1.25, 15.0]; + $this->assertSame($expect, $this->model->interpolatePoints(0.5)); } public function testInterpolatePointsCircle() @@ -168,7 +168,7 @@ public function testInterpolatePointsCircle() $this->model->shape_id = Shape::circleId(); $this->model->points = [[0, 0, 5], [10, 10, 10]]; $this->model->frames = [0.0, 1.0]; - $this->assertEquals([5, 5, 7.5], $this->model->interpolatePoints(0.5)); + $this->assertSame([5.0, 5.0, 7.5], $this->model->interpolatePoints(0.5)); } public function testInterpolatePointsLineString() @@ -368,7 +368,7 @@ public function testScopeAllowedBySessionHideBoth() ]); $ids = VideoAnnotation::allowedBySession($session, $ownUser)->pluck('id')->toArray(); - $this->assertEquals([$a3->id], $ids); + $this->assertSame([$a3->id], $ids); } public function testScopeVisibleFor() @@ -395,18 +395,18 @@ public function testScopeWithLabel() $al1 = VideoAnnotationLabelTest::create(); $al2 = VideoAnnotationLabelTest::create(); - $this->assertEquals($al1->annotation->id, VideoAnnotation::withLabel($al1->label)->first()->id); + $this->assertSame($al1->annotation->id, VideoAnnotation::withLabel($al1->label)->first()->id); } public function testGetPoints() { $annotation = static::make(['points' => [[1, 2]]]); - $this->assertEquals([[1, 2]], $annotation->getPoints()); + $this->assertSame([[1, 2]], $annotation->getPoints()); } public function testGetShape() { - $this->assertEquals($this->model->shape, $this->model->getShape()); + $this->assertSame($this->model->shape, $this->model->getShape()); } public function testGetFile() @@ -416,6 +416,6 @@ public function testGetFile() public function testGetFileIdAttribute() { - $this->assertEquals($this->model->video_id, $this->model->file_id); + $this->assertSame($this->model->video_id, $this->model->file_id); } } diff --git a/tests/php/VideoTest.php b/tests/php/VideoTest.php index 19bb254e1..3a941db29 100644 --- a/tests/php/VideoTest.php +++ b/tests/php/VideoTest.php @@ -22,7 +22,7 @@ public function testAttributes() $this->assertNotNull($this->model->url); $this->assertNotNull($this->model->volume); $this->assertNotNull($this->model->duration); - $this->assertEquals([], $this->model->attrs); + $this->assertSame([], $this->model->attrs); } public function testAnnotations() @@ -64,51 +64,51 @@ public function testGetErrorAttribute() { $this->assertNull($this->model->error); $this->model->attrs = ['error' => 'not-found']; - $this->assertEquals('not-found', $this->model->error); + $this->assertSame('not-found', $this->model->error); } public function testSetErrorAttribute() { $this->model->error = 'not-found'; - $this->assertEquals(['error' => 'not-found'], $this->model->attrs); + $this->assertSame(['error' => 'not-found'], $this->model->attrs); } public function testGetMimeTypeAttribute() { $this->assertNull($this->model->mimeType); $this->model->attrs = ['mimetype' => 'video/mp4']; - $this->assertEquals('video/mp4', $this->model->mimeType); + $this->assertSame('video/mp4', $this->model->mimeType); } public function testSetMimeTypeAttribute() { $this->model->mimeType = 'video/mp4'; - $this->assertEquals(['mimetype' => 'video/mp4'], $this->model->attrs); + $this->assertSame(['mimetype' => 'video/mp4'], $this->model->attrs); } public function testGetSizeAttribute() { $this->assertNull($this->model->size); $this->model->attrs = ['size' => 123]; - $this->assertEquals(123, $this->model->size); + $this->assertSame(123, $this->model->size); } public function testSetSizeAttribute() { $this->model->size = 123; - $this->assertEquals(['size' => 123], $this->model->attrs); + $this->assertSame(['size' => 123], $this->model->attrs); } public function testSetWidthAttribute() { $this->model->width = 123; - $this->assertEquals(['width' => 123], $this->model->attrs); + $this->assertSame(['width' => 123], $this->model->attrs); } public function testSetHeightAttribute() { $this->model->height = 123; - $this->assertEquals(['height' => 123], $this->model->attrs); + $this->assertSame(['height' => 123], $this->model->attrs); } public function testHasBeenProcessed() @@ -121,9 +121,9 @@ public function testHasBeenProcessed() public function testLabels() { $vl = VideoLabelTest::create(['video_id' => $this->model->id]); - $this->assertEquals(1, $this->model->labels()->count()); + $this->assertSame(1, $this->model->labels()->count()); $label = $this->model->labels()->first(); - $this->assertEquals($vl->id, $label->id); + $this->assertSame($vl->id, $label->id); } public function testImagesDeletedEventOnDelete() @@ -141,8 +141,8 @@ public function testTakenAt() $this->model->taken_at = [$now, $then]; $this->model->save(); $takenAt = $this->model->fresh()->taken_at; - $this->assertEquals($now->timestamp, $takenAt[0]->timestamp); - $this->assertEquals($then->timestamp, $takenAt[1]->timestamp); + $this->assertSame($now->timestamp, $takenAt[0]->timestamp); + $this->assertSame($then->timestamp, $takenAt[1]->timestamp); } public function testSetGetLngAttribute() @@ -151,7 +151,7 @@ public function testSetGetLngAttribute() $this->assertNull($this->model->lng); $this->model->lng = $expect; $this->model->save(); - $this->assertEquals($expect, $this->model->fresh()->lng); + $this->assertSame($expect, $this->model->fresh()->lng); } public function testSetGetLatAttribute() @@ -160,15 +160,15 @@ public function testSetGetLatAttribute() $this->assertNull($this->model->lat); $this->model->lat = $expect; $this->model->save(); - $this->assertEquals($expect, $this->model->fresh()->lat); + $this->assertSame($expect, $this->model->fresh()->lat); } public function testSetGetMetadataAttribute() { $expect = ['area' => [2.6, 1.6]]; - $this->assertEquals([], $this->model->metadata); + $this->assertSame([], $this->model->metadata); $this->model->metadata = $expect; $this->model->save(); - $this->assertEquals($expect, $this->model->fresh()->metadata); + $this->assertSame($expect, $this->model->fresh()->metadata); } } diff --git a/tests/php/VisibilityTest.php b/tests/php/VisibilityTest.php index 33f7c5999..46847562d 100644 --- a/tests/php/VisibilityTest.php +++ b/tests/php/VisibilityTest.php @@ -34,11 +34,11 @@ public function testNameUnique() public function testPublic() { - $this->assertEquals('public', Visibility::public()->name); + $this->assertSame('public', Visibility::public()->name); } public function testPrivate() { - $this->assertEquals('private', Visibility::private()->name); + $this->assertSame('private', Visibility::private()->name); } } diff --git a/tests/php/VolumeTest.php b/tests/php/VolumeTest.php index 504a9ea2c..199caaafc 100644 --- a/tests/php/VolumeTest.php +++ b/tests/php/VolumeTest.php @@ -72,23 +72,23 @@ public function testCreatorOnDeleteSetNull() public function testImages() { $image = ImageTest::create(['volume_id' => $this->model->id]); - $this->assertEquals($image->id, $this->model->images()->first()->id); + $this->assertSame($image->id, $this->model->images()->first()->id); } public function testVideos() { $video = VideoTest::create(['volume_id' => $this->model->id]); - $this->assertEquals($video->id, $this->model->videos()->first()->id); + $this->assertSame($video->id, $this->model->videos()->first()->id); } public function testFiles() { $image = ImageTest::create(['volume_id' => $this->model->id]); $video = VideoTest::create(['volume_id' => $this->model->id]); - $this->assertEquals($image->uuid, $this->model->files()->first()->uuid); + $this->assertSame($image->uuid, $this->model->files()->first()->uuid); $this->model->media_type_id = MediaType::videoId(); $this->model->save(); - $this->assertEquals($video->uuid, $this->model->files()->first()->uuid); + $this->assertSame($video->uuid, $this->model->files()->first()->uuid); } public function testIsImageVolume() @@ -110,34 +110,34 @@ public function testIsVideoVolume() public function testProjects() { $project = ProjectTest::create(); - $this->assertEquals(0, $this->model->projects()->count()); + $this->assertSame(0, $this->model->projects()->count()); $project->volumes()->attach($this->model); - $this->assertEquals(1, $this->model->projects()->count()); + $this->assertSame(1, $this->model->projects()->count()); } public function testCastsAttrs() { $this->model->attrs = [1, 2, 3]; $this->model->save(); - $this->assertEquals([1, 2, 3], $this->model->fresh()->attrs); + $this->assertSame([1, 2, 3], $this->model->fresh()->attrs); } public function testParseFilesQueryString() { $return = Volume::parseFilesQueryString(''); - $this->assertEquals([], $return); + $this->assertSame([], $return); $return = Volume::parseFilesQueryString(', 1.jpg , , 2.jpg, , , '); - $this->assertEquals(['1.jpg', '2.jpg'], $return); + $this->assertSame(['1.jpg', '2.jpg'], $return); $return = Volume::parseFilesQueryString(' 1.jpg '); - $this->assertEquals(['1.jpg'], $return); + $this->assertSame(['1.jpg'], $return); $return = Volume::parseFilesQueryString("'1.jpg', '2.jpg'"); - $this->assertEquals(['1.jpg', '2.jpg'], $return); + $this->assertSame(['1.jpg', '2.jpg'], $return); $return = Volume::parseFilesQueryString('"1.jpg", "2.jpg"'); - $this->assertEquals(['1.jpg', '2.jpg'], $return); + $this->assertSame(['1.jpg', '2.jpg'], $return); } public function testImagesDeletedEventOnDelete() @@ -182,7 +182,7 @@ public function testActiveAnnotationSession() 'ends_at' => Carbon::yesterday(), ]); - $this->assertEquals($active->id, $this->model->activeAnnotationSession->id); + $this->assertSame($active->id, $this->model->activeAnnotationSession->id); } public function testHasConflictingAnnotationSession() @@ -293,11 +293,11 @@ public function testUsers() $users = $this->model->users()->get(); // project creators are counted, too - $this->assertEquals(5, $users->count()); - $this->assertEquals(1, $users->where('id', $u1->id)->count()); - $this->assertEquals(1, $users->where('id', $u2->id)->count()); - $this->assertEquals(1, $users->where('id', $u3->id)->count()); - $this->assertEquals(0, $users->where('id', $u4->id)->count()); + $this->assertSame(5, $users->count()); + $this->assertSame(1, $users->where('id', $u1->id)->count()); + $this->assertSame(1, $users->where('id', $u2->id)->count()); + $this->assertSame(1, $users->where('id', $u3->id)->count()); + $this->assertSame(0, $users->where('id', $u4->id)->count()); } public function testIsRemote() @@ -320,7 +320,7 @@ public function testOrderedImages() 'filename' => 'a.jpg', 'volume_id' => $this->model->id, ]); - $this->assertEquals('a.jpg', $this->model->orderedImages()->first()->filename); + $this->assertSame('a.jpg', $this->model->orderedImages()->first()->filename); } public function testOrderedFilesImage() @@ -333,7 +333,7 @@ public function testOrderedFilesImage() 'filename' => 'a.jpg', 'volume_id' => $this->model->id, ]); - $this->assertEquals('a.jpg', $this->model->orderedFiles()->first()->filename); + $this->assertSame('a.jpg', $this->model->orderedFiles()->first()->filename); } public function testOrderedFilesVideo() @@ -348,12 +348,12 @@ public function testOrderedFilesVideo() 'filename' => 'a.mp4', 'volume_id' => $this->model->id, ]); - $this->assertEquals('a.mp4', $this->model->orderedFiles()->first()->filename); + $this->assertSame('a.mp4', $this->model->orderedFiles()->first()->filename); } public function testGetThumbnailAttributeNull() { - $this->assertEquals(null, $this->model->thumbnail); + $this->assertSame(null, $this->model->thumbnail); } public function testGetThumbnailAttributeImage() @@ -372,11 +372,11 @@ public function testGetThumbnailAttributeImage() ]); // Should be the middle image ordered by name. - $this->assertEquals($i2->uuid, $this->model->thumbnail->uuid); + $this->assertSame($i2->uuid, $this->model->thumbnail->uuid); // If the thumbnail is deleted, purge the cache so a new thumbnail is selected. $i2->delete(); - $this->assertEquals($i1->uuid, $this->model->thumbnail->uuid); + $this->assertSame($i1->uuid, $this->model->thumbnail->uuid); } public function testGetThumbnailAttributeVideo() @@ -397,11 +397,11 @@ public function testGetThumbnailAttributeVideo() ]); // Should be the middle image ordered by name. - $this->assertEquals($v2->uuid, $this->model->thumbnail->uuid); + $this->assertSame($v2->uuid, $this->model->thumbnail->uuid); // If the thumbnail is deleted, purge the cache so a new thumbnail is selected. $v2->delete(); - $this->assertEquals($v1->uuid, $this->model->thumbnail->uuid); + $this->assertSame($v1->uuid, $this->model->thumbnail->uuid); } public function testHasGeoInfo() @@ -447,7 +447,7 @@ public function testHandleAttribute() { $this->model->handle = '10.3389/fmars.2017.00083'; $this->model->save(); - $this->assertEquals('10.3389/fmars.2017.00083', $this->model->fresh()->handle); + $this->assertSame('10.3389/fmars.2017.00083', $this->model->fresh()->handle); } public function testScopeAccessibleBy() @@ -468,10 +468,10 @@ public function testScopeAccessibleBy() public function testSanitizeUrl() { $this->model->url = 'http://example.com/images/'; - $this->assertEquals('http://example.com/images', $this->model->url); + $this->assertSame('http://example.com/images', $this->model->url); $this->model->url = 'disk://'; - $this->assertEquals('disk://', $this->model->url); + $this->assertSame('disk://', $this->model->url); } public function testGetThumbnailsAttribute() @@ -623,6 +623,6 @@ public function testGetIfdo() $this->assertNull($this->model->getIfdo()); $disk->put($this->model->id.'.yaml', 'abc: def'); $ifdo = $this->model->getIfdo(); - $this->assertEquals(['abc' => 'def'], $ifdo); + $this->assertSame(['abc' => 'def'], $ifdo); } } From 5e05711d26c866a79da400a9bb8fc5b354f599a3 Mon Sep 17 00:00:00 2001 From: Leane Schlundt Date: Thu, 22 Aug 2024 08:40:05 +0200 Subject: [PATCH 2/5] Use numeric values for metadata --- .../Api/Volumes/MetadataController.php | 5 +++-- .../Api/Volumes/MetadataControllerTest.php | 16 ++++++++-------- tests/php/Jobs/CreateNewImagesOrVideosTest.php | 10 +++++----- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/Api/Volumes/MetadataController.php b/app/Http/Controllers/Api/Volumes/MetadataController.php index 7ba285721..efead8095 100644 --- a/app/Http/Controllers/Api/Volumes/MetadataController.php +++ b/app/Http/Controllers/Api/Volumes/MetadataController.php @@ -101,8 +101,9 @@ protected function updateImageMetadata(StoreVolumeMetadata $request) } $image->fillable(ImageMetadata::ALLOWED_ATTRIBUTES); $image->fill($fill->toArray()); - - $metadata = $row->only(ImageMetadata::ALLOWED_METADATA); + $metadata = $row + ->only(ImageMetadata::ALLOWED_METADATA) + ->map(fn ($str) => strpos($str, '.') ? floatval($str) : intval($str)); $image->metadata = array_merge($image->metadata, $metadata->toArray()); $image->save(); } diff --git a/tests/php/Http/Controllers/Api/Volumes/MetadataControllerTest.php b/tests/php/Http/Controllers/Api/Volumes/MetadataControllerTest.php index df5209f34..a10067672 100644 --- a/tests/php/Http/Controllers/Api/Volumes/MetadataControllerTest.php +++ b/tests/php/Http/Controllers/Api/Volumes/MetadataControllerTest.php @@ -63,12 +63,12 @@ public function testStoreImageMetadata() $this->assertSame('2016-12-19 12:27:00', $jpg->taken_at->toDateTimeString()); $this->assertSame(52.220, $jpg->lng); $this->assertSame(28.123, $jpg->lat); - $this->assertSame(-1500, intval($jpg->metadata['gps_altitude'])); - $this->assertSame(2.6, floatval($jpg->metadata['area'])); + $this->assertSame(-1500, $jpg->metadata['gps_altitude']); + $this->assertSame(2.6, $jpg->metadata['area']); // Import should update but not destroy existing metadata. - $this->assertSame(10, intval($jpg->metadata['distance_to_ground'])); + $this->assertSame(10, $jpg->metadata['distance_to_ground']); $this->assertSame(4000, $jpg->metadata['water_depth']); - $this->assertSame(180, intval($jpg->metadata['yaw'])); + $this->assertSame(180, $jpg->metadata['yaw']); $this->assertNull($png->taken_at); $this->assertNull($png->lng); @@ -107,8 +107,8 @@ public function testStoreDeprecatedFileAttribute() $image->refresh(); $this->assertSame(4000, $image->metadata['water_depth']); - $this->assertSame(10, intval($image->metadata['distance_to_ground'])); - $this->assertSame(2.6, floatval($image->metadata['area'])); + $this->assertSame(10, $image->metadata['distance_to_ground']); + $this->assertSame(2.6, $image->metadata['area']); } public function testStoreImageMetadataText() @@ -131,8 +131,8 @@ public function testStoreImageMetadataText() $image->refresh(); $this->assertSame(4000, $image->metadata['water_depth']); - $this->assertSame(10, intval($image->metadata['distance_to_ground'])); - $this->assertSame(2.5, floatval($image->metadata['area'])); + $this->assertSame(10, $image->metadata['distance_to_ground']); + $this->assertSame(2.5, $image->metadata['area']); } public function testStoreVideoMetadataCsv() diff --git a/tests/php/Jobs/CreateNewImagesOrVideosTest.php b/tests/php/Jobs/CreateNewImagesOrVideosTest.php index 6dce211e1..fc7ee3abd 100644 --- a/tests/php/Jobs/CreateNewImagesOrVideosTest.php +++ b/tests/php/Jobs/CreateNewImagesOrVideosTest.php @@ -69,7 +69,7 @@ public function testHandleImageMetadata() $filenames = ['a.jpg']; $metadata = [ ['filename', 'taken_at', 'lng', 'lat', 'gps_altitude', 'distance_to_ground', 'area', 'yaw'], - ['a.jpg', '2016-12-19 12:27:00', '52.220', '28.123', '-1500', '10', '2.6', '180'], + ['a.jpg', '2016-12-19 12:27:00', '52.220', '28.123', -1500, 10, 2.6, 180], ]; with(new CreateNewImagesOrVideos($volume, $filenames, $metadata))->handle(); @@ -77,10 +77,10 @@ public function testHandleImageMetadata() $this->assertSame('2016-12-19 12:27:00', $image->taken_at->toDateTimeString()); $this->assertSame(52.220, $image->lng); $this->assertSame(28.123, $image->lat); - $this->assertSame(-1500, intval($image->metadata['gps_altitude'])); - $this->assertSame(2.6, floatval($image->metadata['area'])); - $this->assertSame(10, intval($image->metadata['distance_to_ground'])); - $this->assertSame(180, intval($image->metadata['yaw'])); + $this->assertSame(-1500, $image->metadata['gps_altitude']); + $this->assertSame(2.6, $image->metadata['area']); + $this->assertSame(10, $image->metadata['distance_to_ground']); + $this->assertSame(180, $image->metadata['yaw']); } public function testHandleImageMetadataEmptyCells() From 003bc8380bce8298a5674e262dd99795227076a0 Mon Sep 17 00:00:00 2001 From: Leane Schlundt Date: Thu, 22 Aug 2024 09:06:11 +0200 Subject: [PATCH 3/5] Fix wrong numerical representation --- tests/php/Jobs/ProcessNewImageTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/php/Jobs/ProcessNewImageTest.php b/tests/php/Jobs/ProcessNewImageTest.php index 5184f515f..7bf04cc38 100644 --- a/tests/php/Jobs/ProcessNewImageTest.php +++ b/tests/php/Jobs/ProcessNewImageTest.php @@ -70,14 +70,14 @@ public function testHandleCollectMetadataAreaYaw() $job = new ProcessNewImageMock($image); $job->exif = [ - 'GPSImgDirection' => 47.75, - 'SubjectArea' => 2.6, + 'GPSImgDirection' => "191/4", + 'SubjectArea' => "13/5", ]; $job->handle(); $image = $image->fresh(); - $this->assertSame(47.75, floatval($image->metadata['yaw'])); - $this->assertSame(2.6, floatval($image->metadata['area'])); + $this->assertSame(47.75, $image->metadata['yaw']); + $this->assertSame(2.6, $image->metadata['area']); } public function testHandleMakeThumbnail() From 4ef3d5b4859a9ec3e84e8e61366f8f270f6255b1 Mon Sep 17 00:00:00 2001 From: Leane Schlundt Date: Thu, 22 Aug 2024 09:08:05 +0200 Subject: [PATCH 4/5] Fix wrong type --- tests/php/Jobs/ProcessNewVideoTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/php/Jobs/ProcessNewVideoTest.php b/tests/php/Jobs/ProcessNewVideoTest.php index a6869dacd..19788f7cb 100644 --- a/tests/php/Jobs/ProcessNewVideoTest.php +++ b/tests/php/Jobs/ProcessNewVideoTest.php @@ -18,10 +18,10 @@ public function testHandleThumbnails() config(['videos.thumbnail_count' => 3]); $video = VideoTest::create(['filename' => 'test.mp4']); $job = new ProcessNewVideoStub($video); - $job->duration = 10; + $job->duration = 10.0; $job->handle(); - $this->assertSame(10, intval($video->fresh()->duration)); + $this->assertSame(10.0, $video->fresh()->duration); $this->assertSame([0.5, 5.0, 9.5], $job->times); $disk = Storage::disk('video-thumbs'); From 93554c63069a8db1226c2f566dfa65a32f7d4aeb Mon Sep 17 00:00:00 2001 From: Leane Schlundt Date: Thu, 22 Aug 2024 09:12:03 +0200 Subject: [PATCH 5/5] Use assertEquals for simplicity --- .../Http/Controllers/Api/ProjectInvitationControllerTest.php | 2 +- tests/php/Services/Auth/ApiGuardTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php b/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php index 26cb79838..4b347ee59 100644 --- a/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php +++ b/tests/php/Http/Controllers/Api/ProjectInvitationControllerTest.php @@ -41,7 +41,7 @@ public function testStore() $invitation = $this->project()->invitations()->first(); $this->assertNotNull($invitation); - $this->assertSame($timestamp->toDateTimeString(), $invitation->expires_at->tz($timestamp->timezone)->toDateTimeString()); + $this->assertEquals($timestamp, $invitation->expires_at); $this->assertSame(0, $invitation->current_uses); $this->assertNotNull($invitation->uuid); $this->assertNull($invitation->max_uses); diff --git a/tests/php/Services/Auth/ApiGuardTest.php b/tests/php/Services/Auth/ApiGuardTest.php index 65465b284..17e2b316b 100644 --- a/tests/php/Services/Auth/ApiGuardTest.php +++ b/tests/php/Services/Auth/ApiGuardTest.php @@ -120,7 +120,7 @@ public function testTouchToken() $token->updated_at = Carbon::now(-5); $token->save(); - $this->assertSame($token->updated_at->toDateTimeString(), $token->fresh()->updated_at->toDateTimeString()); + $this->assertEquals($token->updated_at, $token->fresh()->updated_at); $response = $this->call('GET', '/api/v1/users', [], [], [], [ 'PHP_AUTH_USER' => $token->owner->email,