Skip to content

Commit acdc6d1

Browse files
authored
Merge pull request #905 from bavix/fix-initializeMorphOneWallet
[10.x] fix initializeMorphOneWallet
2 parents 4aa14e5 + 7832198 commit acdc6d1

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Models/Wallet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function getCurrencyAttribute(): string
161161

162162
protected function initializeMorphOneWallet(): void
163163
{
164-
$this->uuid = app(UuidFactoryServiceInterface::class)->uuid4();
164+
$this->uuid ??= app(UuidFactoryServiceInterface::class)->uuid4();
165165
}
166166

167167
/**

tests/Units/Domain/EagerLoadingTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ final class EagerLoadingTest extends TestCase
2222
{
2323
public function testUuidDuplicate(): void
2424
{
25+
$expected = [];
26+
2527
/** @var Collection<int, Buyer> $buyerTimes */
2628
$buyerTimes = BuyerFactory::times(10)->create();
2729
foreach ($buyerTimes as $buyerTime) {
2830
self::assertTrue($buyerTime->wallet->relationLoaded('holder'));
2931
$buyerTime->deposit(100);
32+
$expected[] = $buyerTime->wallet->uuid;
3033
}
3134

3235
/** @var Collection<int, Buyer> $buyers */
@@ -47,6 +50,7 @@ public function testUuidDuplicate(): void
4750

4851
self::assertCount(10, array_unique($uuids));
4952
self::assertCount(1, array_unique($balances));
53+
self::assertEquals($expected, $uuids);
5054
}
5155

5256
public function testTransferTransactions(): void

0 commit comments

Comments
 (0)