Skip to content

Commit

Permalink
fix initializeMorphOneWallet
Browse files Browse the repository at this point in the history
  • Loading branch information
rez1dent3 committed Mar 9, 2024
1 parent d1c668f commit 85a6e9e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Models/Wallet.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ public function getCurrencyAttribute(): string

protected function initializeMorphOneWallet(): void
{
$this->uuid = app(UuidFactoryServiceInterface::class)->uuid4();
$this->uuid ??= app(UuidFactoryServiceInterface::class)->uuid4();
}
}
4 changes: 4 additions & 0 deletions tests/Units/Domain/EagerLoadingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ final class EagerLoadingTest extends TestCase
{
public function testUuidDuplicate(): void
{
$expected = [];

/** @var Buyer[]|Collection $buyerTimes */
$buyerTimes = BuyerFactory::times(10)->create();
foreach ($buyerTimes as $buyerTime) {
self::assertTrue($buyerTime->wallet->relationLoaded('holder'));
$buyerTime->deposit(100);
$expected[] = $buyerTime->wallet->uuid;
}

/** @var Buyer[] $buyers */
Expand All @@ -47,6 +50,7 @@ public function testUuidDuplicate(): void

self::assertCount(10, array_unique($uuids));
self::assertCount(1, array_unique($balances));
self::assertEquals($expected, $uuids);
}

public function testTransferTransactions(): void
Expand Down

0 comments on commit 85a6e9e

Please sign in to comment.