Skip to content

Commit 778d049

Browse files
committed
fix unit-cases
1 parent ed29630 commit 778d049

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/BalanceTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,41 @@
1111
class BalanceTest extends TestCase
1212
{
1313

14+
/**
15+
* @return void
16+
*/
17+
public function testDepositWalletExists(): void
18+
{
19+
/**
20+
* @var Buyer $buyer
21+
*/
22+
$buyer = factory(Buyer::class)->create();
23+
$this->assertFalse($buyer->relationLoaded('wallet'));
24+
$buyer->deposit(1);
25+
26+
$this->assertTrue($buyer->relationLoaded('wallet'));
27+
$this->assertTrue($buyer->wallet->exists);
28+
}
29+
30+
/**
31+
* @return void
32+
*/
33+
public function testWithdrawWalletExists(): void
34+
{
35+
/**
36+
* @var Buyer $buyer
37+
*/
38+
$buyer = factory(Buyer::class)->create();
39+
$this->assertFalse($buyer->relationLoaded('wallet'));
40+
$this->assertEquals($buyer->balance, 0);
41+
$buyer->forceWithdraw(1);
42+
43+
$this->assertEquals($buyer->balance, -1);
44+
$this->assertTrue($buyer->relationLoaded('wallet'));
45+
$this->assertTrue($buyer->wallet->exists);
46+
$this->assertLessThan(0, $buyer->balance);
47+
}
48+
1449
/**
1550
* @return void
1651
* @throws
@@ -21,9 +56,13 @@ public function testSimple(): void
2156
* @var Buyer $buyer
2257
*/
2358
$buyer = factory(Buyer::class)->create();
59+
60+
$this->assertFalse($buyer->relationLoaded('wallet'));
2461
$wallet = $buyer->wallet;
2562

63+
$this->assertFalse($wallet->exists);
2664
$this->assertEquals($wallet->balance, 0);
65+
$this->assertTrue($wallet->exists);
2766

2867
$wallet->deposit(1000);
2968
$this->assertEquals($wallet->balance, 1000);

0 commit comments

Comments
 (0)