Skip to content

Commit f067822

Browse files
committed
fix units
1 parent e8bac3b commit f067822

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/Services/WalletServiceLegacy.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
/** @deprecated */
1515
final class WalletServiceLegacy
1616
{
17-
private MathServiceInterface $math;
17+
private MathServiceInterface $mathService;
1818
private RegulatorServiceInterface $regulatorService;
1919
private AtomicServiceInterface $atomicService;
2020

2121
public function __construct(
22-
MathServiceInterface $math,
22+
MathServiceInterface $mathService,
2323
RegulatorServiceInterface $regulatorService,
2424
AtomicServiceInterface $atomicService
2525
) {
26-
$this->math = $math;
26+
$this->mathService = $mathService;
2727
$this->regulatorService = $regulatorService;
2828
$this->atomicService = $atomicService;
2929
}
@@ -42,7 +42,7 @@ public function refresh(WalletModel $wallet): bool
4242
return $this->atomicService->block($wallet, function () use ($wallet) {
4343
$whatIs = $wallet->balance;
4444
$balance = $wallet->getAvailableBalance();
45-
if ($this->math->compare($whatIs, $balance) === 0) {
45+
if ($this->mathService->compare($whatIs, $balance) === 0) {
4646
return true;
4747
}
4848

tests/Infra/TestCase.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Config\Repository;
1212
use Illuminate\Foundation\Application;
1313
use Illuminate\Foundation\Testing\RefreshDatabase;
14+
use Illuminate\Support\Facades\DB;
1415
use Orchestra\Testbench\TestCase as OrchestraTestCase;
1516

1617
/**
@@ -20,6 +21,12 @@ class TestCase extends OrchestraTestCase
2021
{
2122
use RefreshDatabase;
2223

24+
protected function setUp(): void
25+
{
26+
parent::setUp();
27+
DB::transactionLevel() && DB::rollBack();
28+
}
29+
2330
public function expectExceptionMessageStrict(string $message): void
2431
{
2532
$this->expectExceptionMessageMatches("~^{$message}$~");

tests/Units/Domain/BalanceTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ public function testSimple(): void
9595
$result = app(CommonServiceLegacy::class)->addBalance($wallet, 100);
9696
self::assertTrue($result);
9797

98-
self::assertSame($wallet->balanceInt, 1100);
98+
self::assertSame(1100, $wallet->balanceInt);
9999
self::assertTrue($wallet->refreshBalance());
100100

101-
self::assertSame($wallet->balanceInt, 1000);
101+
self::assertSame(1000, $wallet->balanceInt);
102102

103103
$key = $wallet->getKey();
104104
self::assertTrue($wallet->delete());
@@ -195,6 +195,7 @@ public function testForceUpdate(): void
195195

196196
$wallet->deposit(1000);
197197
self::assertSame(1000, $wallet->balanceInt);
198+
self::assertSame(0, (int) app(RegulatorServiceInterface::class)->diff($wallet));
198199

199200
Wallet::whereKey($buyer->wallet->getKey())
200201
->update(['balance' => 10])

0 commit comments

Comments
 (0)