Skip to content

Commit a75c422

Browse files
committed
update unit cases
1 parent 947140c commit a75c422

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

tests/GiftTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ public function testGift(): void
3535
$this->assertEquals($second->balance, 0);
3636
$this->assertNull($first->paid($product, true));
3737
$this->assertNotNull($second->paid($product, true));
38+
$this->assertNull($second->wallet->paid($product));
39+
$this->assertNotNull($second->wallet->paid($product, true));
3840
$this->assertEquals($transfer->status, Transfer::STATUS_GIFT);
3941
}
4042

tests/MultiWalletTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@ public function testGetWallet(): void
285285
$test2->getKey(),
286286
$user->getWallet('test2')->getKey()
287287
);
288+
289+
// check default wallet
290+
$this->assertEquals(
291+
$user->balance,
292+
$user->wallet->balance
293+
);
288294
}
289295

290296
}

tests/ProductTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Bavix\Wallet\Test;
44

55
use Bavix\Wallet\Models\Transaction;
6+
use Bavix\Wallet\Models\Transfer;
67
use Bavix\Wallet\Test\Models\Buyer;
78
use Bavix\Wallet\Test\Models\Item;
89

@@ -29,6 +30,7 @@ public function testPay(): void
2930
$this->assertEquals($buyer->balance, $product->price);
3031
$transfer = $buyer->pay($product);
3132
$this->assertNotNull($transfer);
33+
$this->assertEquals($transfer->status, Transfer::STATUS_PAID);
3234

3335
/**
3436
* @var Transaction $withdraw
@@ -74,17 +76,21 @@ public function testRefund(): void
7476
$buyer->deposit($product->price);
7577

7678
$this->assertEquals($buyer->balance, $product->price);
77-
$this->assertNotNull($buyer->pay($product));
79+
$transfer = $buyer->pay($product);
80+
$this->assertNotNull($transfer);
81+
$this->assertEquals($transfer->status, Transfer::STATUS_PAID);
7882

7983
$this->assertTrue($buyer->refund($product));
8084
$this->assertEquals($buyer->balance, $product->price);
8185

8286
$this->assertFalse($buyer->safeRefund($product));
8387
$this->assertEquals($buyer->balance, $product->price);
8488

85-
$this->assertNotNull($buyer->pay($product));
89+
$transfer = $buyer->pay($product);
90+
$this->assertNotNull($transfer);
8691
$this->assertEquals($buyer->balance, 0);
8792
$this->assertEquals($product->balance, $product->price);
93+
$this->assertEquals($transfer->status, Transfer::STATUS_PAID);
8894
}
8995

9096
/**

0 commit comments

Comments
 (0)