mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
Fixed timezone problem in unit tests
This commit is contained in:
committed by
Constantin Graf
parent
8b50f33cc9
commit
78ea8a673b
@@ -147,8 +147,8 @@ class TimeEntryFactory extends Factory
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($start, $durationInSeconds): array {
|
||||
return [
|
||||
'start' => $start->utc(),
|
||||
'end' => $start->copy()->addSeconds($durationInSeconds),
|
||||
'start' => $start->copy()->utc(),
|
||||
'end' => $start->copy()->utc()->addSeconds($durationInSeconds),
|
||||
];
|
||||
});
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class TimeEntryFactory extends Factory
|
||||
{
|
||||
return $this->state(function (array $attributes) use ($start): array {
|
||||
return [
|
||||
'start' => $start->utc(),
|
||||
'start' => $start->copy()->utc(),
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ abstract class TestCase extends BaseTestCase
|
||||
$mock->shouldReceive('getTrialUntil')->andReturn(null);
|
||||
$mock->shouldReceive('isBlocked')->andReturn(false);
|
||||
});
|
||||
// Note: The following line can be used to test timezone edge cases.
|
||||
// $this->travelTo(Carbon::now()->timezone('Europe/Vienna')->setHour(0)->setMinute(59)->setSecond(0));
|
||||
}
|
||||
|
||||
protected function mockPrivateStorage(): void
|
||||
|
||||
@@ -473,8 +473,8 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
'time-entries:view:all',
|
||||
]);
|
||||
$project = Project::factory()->forOrganization($data->organization)->create();
|
||||
$day1 = Carbon::now()->timezone($data->user->timezone)->subDays(1)->utc();
|
||||
$day2 = Carbon::now()->timezone($data->user->timezone)->subDays(3)->utc();
|
||||
$day1 = Carbon::now()->timezone($data->user->timezone)->subDays(1);
|
||||
$day2 = Carbon::now()->timezone($data->user->timezone)->subDays(3);
|
||||
$timeEntry1NoProject = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration($day1, 10)->create();
|
||||
$timeEntry2NoProject = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration($day2, 10)->create();
|
||||
$timeEntry1WithProject = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->forProject($project)->startWithDuration($day1, 10)->create();
|
||||
@@ -552,8 +552,8 @@ class TimeEntryEndpointTest extends ApiEndpointTestAbstract
|
||||
'time-entries:view:all',
|
||||
]);
|
||||
$project = Project::factory()->forOrganization($data->organization)->create();
|
||||
$day1 = Carbon::now()->timezone($data->user->timezone)->subDays(1)->utc();
|
||||
$day2 = Carbon::now()->timezone($data->user->timezone)->subDays(3)->utc();
|
||||
$day1 = Carbon::now()->timezone($data->user->timezone)->subDays(1);
|
||||
$day2 = Carbon::now()->timezone($data->user->timezone)->subDays(3);
|
||||
$timeEntry1NoProject = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration($day1, 10)->create();
|
||||
$timeEntry2NoProject = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->startWithDuration($day2, 10)->create();
|
||||
$timeEntry1WithProject = TimeEntry::factory()->forOrganization($data->organization)->forMember($data->member)->forProject($project)->startWithDuration($day1, 10)->create();
|
||||
|
||||
@@ -140,6 +140,7 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
|
||||
public function test_aggregate_time_entries_empty_state_by_day_and_project_with_filled_gaps(): void
|
||||
{
|
||||
// Arrange
|
||||
$timezone = 'Europe/Vienna';
|
||||
$query = TimeEntry::query();
|
||||
|
||||
// Act
|
||||
@@ -147,7 +148,7 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
|
||||
$query,
|
||||
TimeEntryAggregationType::Day,
|
||||
TimeEntryAggregationType::Project,
|
||||
'Europe/Vienna',
|
||||
$timezone,
|
||||
Weekday::Monday,
|
||||
true,
|
||||
Carbon::now()->subDays(2)->utc(),
|
||||
@@ -161,14 +162,14 @@ class TimeEntryAggregationServiceTest extends TestCaseWithDatabase
|
||||
'grouped_type' => 'day',
|
||||
'grouped_data' => [
|
||||
[
|
||||
'key' => Carbon::now()->subDays(2)->utc()->format('Y-m-d'),
|
||||
'key' => Carbon::now()->subDays(2)->timezone($timezone)->format('Y-m-d'),
|
||||
'seconds' => 0,
|
||||
'cost' => 0,
|
||||
'grouped_type' => 'project',
|
||||
'grouped_data' => [],
|
||||
],
|
||||
[
|
||||
'key' => Carbon::now()->subDay()->utc()->format('Y-m-d'),
|
||||
'key' => Carbon::now()->subDay()->timezone($timezone)->format('Y-m-d'),
|
||||
'seconds' => 0,
|
||||
'cost' => 0,
|
||||
'grouped_type' => 'project',
|
||||
|
||||
Reference in New Issue
Block a user