Skip to content

Commit 0e0b5dd

Browse files
committed
update units
1 parent 45868cb commit 0e0b5dd

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

config/config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
use Bavix\Wallet\Services\PrepareService;
3535
use Bavix\Wallet\Services\PurchaseService;
3636
use Bavix\Wallet\Services\RegulatorService;
37+
use Bavix\Wallet\Services\StateService;
3738
use Bavix\Wallet\Services\TaxService;
3839

3940
return [
@@ -80,6 +81,7 @@
8081
'basket' => BasketService::class,
8182
'bookkeeper' => BookkeeperService::class,
8283
'regulator' => RegulatorService::class,
84+
'state' => StateService::class,
8385
'cast' => CastService::class,
8486
'consistency' => ConsistencyService::class,
8587
'discount' => DiscountService::class,

src/WalletServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private function contextBinding(array $bookkeeperStore): void
166166
StorageServiceInterface::class,
167167
[
168168
'cacheRepository' => $this->app->make(CacheManager::class)
169-
->driver($bookkeeperStore['driver'] ?? null),
169+
->driver($bookkeeperStore['driver'] ?? 'array'),
170170
],
171171
))
172172
;

tests/Units/Domain/MultiWalletTest.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
use Bavix\Wallet\Internal\Service\UuidFactoryServiceInterface;
1414
use Bavix\Wallet\Models\Transaction;
1515
use Bavix\Wallet\Models\Transfer;
16+
use Bavix\Wallet\Services\BookkeeperServiceInterface;
17+
use Bavix\Wallet\Services\RegulatorServiceInterface;
1618
use Bavix\Wallet\Test\Infra\Factories\ItemFactory;
1719
use Bavix\Wallet\Test\Infra\Factories\UserCashierFactory;
1820
use Bavix\Wallet\Test\Infra\Factories\UserMultiFactory;
@@ -538,6 +540,9 @@ public function testMultiWalletTransactionState(): void
538540
}
539541

540542
self::assertCount(10, $wallets);
543+
foreach ($wallets as $wallet) {
544+
self::assertSame(0, (int) app(RegulatorServiceInterface::class)->diff($wallet));
545+
}
541546

542547
$funds = null;
543548

@@ -548,7 +553,10 @@ public function testMultiWalletTransactionState(): void
548553
$wallet->withdraw(100);
549554
$wallet->deposit(50);
550555

551-
self::assertSame(950 + $key, $wallet->balanceInt);
556+
$value = 950 + $key;
557+
self::assertSame($value, $wallet->balanceInt);
558+
self::assertSame($value, (int) app(RegulatorServiceInterface::class)->amount($wallet));
559+
self::assertSame(0, (int) app(BookkeeperServiceInterface::class)->amount($wallet));
552560
}
553561

554562
$wallet = reset($wallets);
@@ -563,6 +571,8 @@ public function testMultiWalletTransactionState(): void
563571
self::assertNotNull($funds);
564572
foreach ($wallets as $wallet) {
565573
self::assertSame(0, $wallet->balanceInt);
574+
self::assertSame(0, (int) app(RegulatorServiceInterface::class)->diff($wallet));
575+
self::assertSame(0, (int) app(BookkeeperServiceInterface::class)->amount($wallet));
566576
}
567577
}
568578
}

tests/Units/Domain/WalletTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Bavix\Wallet\Internal\Exceptions\TransactionFailedException;
1212
use Bavix\Wallet\Internal\Service\DatabaseServiceInterface;
1313
use Bavix\Wallet\Models\Transaction;
14+
use Bavix\Wallet\Services\BookkeeperServiceInterface;
15+
use Bavix\Wallet\Services\RegulatorServiceInterface;
1416
use Bavix\Wallet\Test\Infra\Factories\UserFactory;
1517
use Bavix\Wallet\Test\Infra\Models\User;
1618
use Bavix\Wallet\Test\Infra\TestCase;
@@ -302,7 +304,10 @@ public function testCrash(): void
302304

303305
try {
304306
app(DatabaseServiceInterface::class)->transaction(static function () use ($user) {
307+
self::assertSame(0, (int) app(RegulatorServiceInterface::class)->diff($user->wallet));
305308
$user->withdraw(10000);
309+
self::assertSame(-10000, (int) app(RegulatorServiceInterface::class)->diff($user->wallet));
310+
self::assertSame(0, (int) app(RegulatorServiceInterface::class)->amount($user->wallet));
306311

307312
throw new RuntimeException('hello world');
308313
});
@@ -315,5 +320,6 @@ public function testCrash(): void
315320
}
316321

317322
self::assertSame(10000, $user->balanceInt);
323+
self::assertSame(0, (int) app(RegulatorServiceInterface::class)->diff($user->wallet));
318324
}
319325
}

0 commit comments

Comments
 (0)