From 0245eccaebb588613456c679db4bd91a4b6e0971 Mon Sep 17 00:00:00 2001 From: Constantin Graf Date: Tue, 27 Aug 2024 17:11:43 +0200 Subject: [PATCH] Fixed broken test --- app/Service/TimeEntryAggregationService.php | 6 ++++++ tests/Unit/Service/Export/ExportServiceTest.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/app/Service/TimeEntryAggregationService.php b/app/Service/TimeEntryAggregationService.php index 3b8648c0..b25c24f9 100644 --- a/app/Service/TimeEntryAggregationService.php +++ b/app/Service/TimeEntryAggregationService.php @@ -65,6 +65,12 @@ public function getAggregatedTimeEntries(Builder $timeEntriesQuery, ?TimeEntryAg if ($groupBy !== null) { $timeEntriesQuery->groupBy($groupBy); } + if ($group1Select !== null) { + $timeEntriesQuery->orderBy('group_1'); + if ($group2Select !== null) { + $timeEntriesQuery->orderBy('group_2'); + } + } $timeEntriesAggregates = $timeEntriesQuery->get(); diff --git a/tests/Unit/Service/Export/ExportServiceTest.php b/tests/Unit/Service/Export/ExportServiceTest.php index c806dc1a..f010883d 100644 --- a/tests/Unit/Service/Export/ExportServiceTest.php +++ b/tests/Unit/Service/Export/ExportServiceTest.php @@ -7,8 +7,10 @@ use App\Models\Client; use App\Models\Member; use App\Models\Organization; +use App\Models\OrganizationInvitation; use App\Models\Project; use App\Models\ProjectMember; +use App\Models\Tag; use App\Models\Task; use App\Models\TimeEntry; use App\Models\User; @@ -27,6 +29,8 @@ private function getFullOrganization(): Organization $user1 = User::factory()->create(); $user2 = User::factory()->create(); $organization = Organization::factory()->withOwner($user1)->create(); + OrganizationInvitation::factory()->forOrganization($organization)->create(); + OrganizationInvitation::factory()->forOrganization($organization)->create(); $member1 = Member::factory()->forUser($user1)->forOrganization($organization)->create(); $member2 = Member::factory()->forUser($user2)->forOrganization($organization)->create(); $timeEntry1 = TimeEntry::factory()->forMember($member1)->create(); @@ -40,6 +44,8 @@ private function getFullOrganization(): Organization $projectMember2 = ProjectMember::factory()->forMember($member2)->forProject($project1)->create(); $client1 = Client::factory()->forOrganization($organization)->create(); $client2 = Client::factory()->forOrganization($organization)->create(); + Tag::factory()->forOrganization($organization)->create(); + Tag::factory()->forOrganization($organization)->create(); return $organization; }