Skip to content

Commit

Permalink
Merge pull request #163 from bavix/develop
Browse files Browse the repository at this point in the history
New Features
  • Loading branch information
rez1dent3 committed Jun 10, 2020
2 parents ce59222 + 73f962e commit 9edd3ae
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
7 changes: 6 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.2.1] - 2020-06-10
### Added
- Added support `laravel/cashier ^12.0`

## [5.2.0] - 2020-04-15
### Added
- Added support `laravel/cashier ^11.0`
Expand Down Expand Up @@ -504,7 +508,8 @@ The operation is now executed in the transaction and updates the new `refund` fi
- Exceptions: AmountInvalid, BalanceIsEmpty.
- Models: Transfer, Transaction.

[Unreleased]: https://github.com/bavix/laravel-wallet/compare/5.2.0...develop
[Unreleased]: https://github.com/bavix/laravel-wallet/compare/5.2.1...develop
[5.2.1]: https://github.com/bavix/laravel-wallet/compare/5.2.0...5.2.1
[5.2.0]: https://github.com/bavix/laravel-wallet/compare/5.1.0...5.2.0
[5.1.0]: https://github.com/bavix/laravel-wallet/compare/5.0.2...5.1.0
[5.0.2]: https://github.com/bavix/laravel-wallet/compare/5.0.1...5.0.2
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"orchestra/testbench": "^4.0|^5.0",
"phpstan/phpstan": "^0.12",
"phpunit/phpunit": "^8.0|^9.0",
"laravel/cashier": "^10.0|^11.0"
"laravel/cashier": "^10.0|^11.0|^12.0"
},
"suggest": {
"ext-bcmath": "Used for accurate calculations of large numbers",
Expand Down
50 changes: 50 additions & 0 deletions tests/DiscountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,56 @@ public function testPay(): void
$this->assertEquals($product->getKey(), $transfer->to->getKey());
}

/**
* @return void
*/
public function testItemTransactions(): void
{
/**
* @var Buyer $buyer
* @var ItemDiscount $product
*/
$buyer = factory(Buyer::class)->create();
$product = factory(ItemDiscount::class)->create();

$this->assertEquals($buyer->balance, 0);
$buyer->deposit($product->getAmountProduct($buyer));

$this->assertEquals($buyer->balance, $product->getAmountProduct($buyer));
$transfer = $buyer->pay($product);
$this->assertNotNull($transfer);
$this->assertEquals($transfer->status, Transfer::STATUS_PAID);

$this->assertEquals(
$buyer->balance,
$product->getPersonalDiscount($buyer)
);

$this->assertEquals(
$transfer->discount,
$product->getPersonalDiscount($buyer)
);

/**
* @var Transaction $withdraw
* @var Transaction $deposit
*/
$withdraw = $transfer->withdraw;
$deposit = $transfer->deposit;

$this->assertInstanceOf(Transaction::class, $withdraw);
$this->assertInstanceOf(Transaction::class, $deposit);

$this->assertTrue($withdraw->is(
$buyer->transactions()
->where('type', Transaction::TYPE_WITHDRAW)
->latest()
->first()
));

$this->assertTrue($deposit->is($product->transactions()->latest()->first()));
}

/**
* @return void
*/
Expand Down

0 comments on commit 9edd3ae

Please sign in to comment.