Skip to content

Commit

Permalink
Merge pull request #906 from bavix/11.x-fix-initializeMorphOneWallet
Browse files Browse the repository at this point in the history
[11.x] fix initializeMorphOneWallet
  • Loading branch information
rez1dent3 authored Mar 9, 2024
2 parents 41deb46 + 84efe9a commit 63c3425
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 @@ -168,6 +168,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 Collection<int, Buyer> $buyerTimes */
$buyerTimes = BuyerFactory::times(10)->create();
foreach ($buyerTimes as $buyerTime) {
self::assertTrue($buyerTime->wallet->relationLoaded('holder'));
$buyerTime->deposit(100);
$expected[] = $buyerTime->wallet->uuid;
}

/** @var Collection<int, Buyer> $buyers */
Expand All @@ -46,6 +49,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 63c3425

Please sign in to comment.