From 140f7d5a9367834b173624a5f9a8beae510db26c Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Mon, 28 Oct 2024 17:00:51 -0500 Subject: [PATCH] tests:use correct span for sync daily changes --- tests/SyncDailyChangeTest.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/SyncDailyChangeTest.php b/tests/SyncDailyChangeTest.php index dc3bf45..a816b2d 100644 --- a/tests/SyncDailyChangeTest.php +++ b/tests/SyncDailyChangeTest.php @@ -9,6 +9,7 @@ use Carbon\CarbonPeriod; use App\Models\Portfolio; use App\Models\DailyChange; use App\Models\Transaction; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Artisan; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -34,7 +35,11 @@ class SyncDailyChangeTest extends TestCase $portfolio->syncDailyChanges(); $count_of_daily_changes = $portfolio->daily_change()->count('date'); - $days_between_now_and_first_trans = (int) CarbonPeriod::create($portfolio->transactions()->min('date'), now())->filter('isWeekday')->count(); + $days_between_now_and_first_trans = (int) CarbonPeriod::create( + $portfolio->transactions()->min('date'), + now()->isBefore(Carbon::parse(config('investbrain.daily_change_time_of_day'))) ? now()->subDay() : now() + )->filter('isWeekday') + ->count(); $this->assertEquals($count_of_daily_changes, $days_between_now_and_first_trans); }