BalanceOrderPaidSuccessTest.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of ibrand/balace.
  4. *
  5. * (c) GuoJiangClub <https://www.ibrand.cc>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace GuoJiangClub\Component\Balance\Test;
  11. use GuoJiangClub\Component\Balance\Balance;
  12. use GuoJiangClub\Component\Balance\BalanceOrder;
  13. use Illuminate\Foundation\Testing\DatabaseMigrations;
  14. class BalanceOrderPaidSuccessTest extends BaseTest
  15. {
  16. use DatabaseMigrations;
  17. public function testPaidSuccessEvent()
  18. {
  19. $order = BalanceOrder::create(['user_id' => 3, 'order_no' => 'R123456', 'pay_type' => 'alipay_wap', 'pay_status' => BalanceOrder::STATUS_NEW, 'amount' => '8000', 'pay_amount' => '8000']);
  20. $this->assertSame('GuoJiangClub\Component\Balance\BalanceOrder', get_class($order));
  21. event('balance.order.paid.success', [$order]);
  22. $balance = Balance::where('user_id', 3)
  23. ->where('type', Balance::TYPE_RECHARGE)
  24. ->where('origin_id', $order->id)
  25. ->where('origin_type', 'GuoJiangClub\Component\Balance\BalanceOrder')
  26. ->first();
  27. $this->assertSame('8000', $balance->value);
  28. }
  29. }