From 41dac42a73d6b965e9b6bd7c222146fe57ccaf33 Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Wed, 17 Apr 2024 22:04:34 +0300 Subject: [PATCH] Pending Balances #937 --- tests/Units/Domain/ExtraTest.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/Units/Domain/ExtraTest.php b/tests/Units/Domain/ExtraTest.php index a62625df7..ce2104c68 100644 --- a/tests/Units/Domain/ExtraTest.php +++ b/tests/Units/Domain/ExtraTest.php @@ -303,4 +303,31 @@ public function testExtraExchangeWithdraw(): void 'message' => 'Write off from the ruble account', ], $transfer->withdraw->meta); } + + public function testPendingBalances(): void + { + /** @var Buyer $user1 */ + /** @var Buyer $user2 */ + [$user1, $user2] = BuyerFactory::times(2)->create(); + + $user1->deposit(1000); + self::assertSame(1000, $user1->balanceInt); + self::assertSame(0, $user2->balanceInt); + + $transfer = $user1->transfer($user2, 500, new Extra( + deposit: new Option(null, confirmed: false), + withdraw: null, + )); + + self::assertNotNull($transfer); + self::assertTrue($transfer->withdraw->confirmed); + self::assertFalse($transfer->deposit->confirmed); + + self::assertSame(500, $user1->balanceInt); + self::assertSame(0, $user2->balanceInt); + + self::assertTrue($user2->wallet->confirm($transfer->deposit)); // confirmed + + self::assertSame(500, $user2->balanceInt); + } }