From bcb182009588b58560170b7acf1c0c7ec6f57ea4 Mon Sep 17 00:00:00 2001 From: hackerESQ Date: Sat, 19 Oct 2024 10:42:28 -0500 Subject: [PATCH] fix test --- tests/DividendsTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/DividendsTest.php b/tests/DividendsTest.php index 9233ba0..d264e3e 100644 --- a/tests/DividendsTest.php +++ b/tests/DividendsTest.php @@ -2,12 +2,13 @@ namespace Tests; -use App\Models\Dividend; use Tests\TestCase; use App\Models\User; use App\Models\Split; use App\Models\Holding; +use App\Models\Dividend; use App\Models\Portfolio; +use App\Models\MarketData; use App\Models\Transaction; use Illuminate\Foundation\Testing\RefreshDatabase; @@ -54,11 +55,10 @@ class DividendsTest extends TestCase $transactions = Transaction::where(['reinvested_dividend' => true])->symbol('ACME')->portfolio($portfolio->id)->get(); - $dividendsReinvested = $transactions->reduce(function ($carry, $transaction) { - return $carry + ($transaction->cost_basis * $transaction->quantity); - }, 0); + $market_data = MarketData::symbol('ACME')->first(); + $dividendsReinvested = $transactions->sum('quantity'); $this->assertCount(3, $transactions); - $this->assertEqualsWithDelta(4.95, $dividendsReinvested, 0.01); + $this->assertEqualsWithDelta(4.95, $dividendsReinvested * $market_data->market_value, 0.01); } }