Skip to content

Commit 1ff4eb0

Browse files
author
Babichev Maxim
committed
#111 add unit-cases
1 parent cf9dc16 commit 1ff4eb0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/TaxTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Bavix\Wallet\Test;
44

5+
use Bavix\Wallet\Exceptions\InsufficientFunds;
56
use Bavix\Wallet\Models\Transaction;
67
use Bavix\Wallet\Test\Models\Buyer;
78
use Bavix\Wallet\Test\Models\ItemTax;
@@ -102,4 +103,32 @@ public function testGift(): void
102103
$this->assertEquals($santa->balance, 0);
103104
}
104105

106+
/**
107+
* @return void
108+
*/
109+
public function testGiftFail(): void
110+
{
111+
$this->expectException(InsufficientFunds::class);
112+
113+
/**
114+
* @var Buyer $santa
115+
* @var Buyer $child
116+
* @var ItemTax $product
117+
*/
118+
[$santa, $child] = factory(Buyer::class, 2)->create();
119+
$product = factory(ItemTax::class)->create([
120+
'quantity' => 1,
121+
]);
122+
123+
$this->assertEquals($santa->balance, 0);
124+
$this->assertEquals($child->balance, 0);
125+
$santa->deposit($product->getAmountProduct());
126+
127+
$this->assertNotEquals($santa->balance, 0);
128+
$this->assertEquals($child->balance, 0);
129+
$santa->wallet->gift($child, $product);
130+
131+
$this->assertEquals($santa->balance, 0);
132+
}
133+
105134
}

0 commit comments

Comments
 (0)