BalanceTest.php 1.2 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. class BalanceTest extends BaseTest
  13. {
  14. public function testBalanceModels()
  15. {
  16. //How much is the current balance of the user
  17. $value_user_1 = Balance::getBalanceByUserId(1);
  18. $this->assertSame('2000', $value_user_1);
  19. $value_user_2 = Balance::getBalanceByUserId(2);
  20. $this->assertSame('1000', $value_user_2);
  21. $value_user_3 = Balance::getBalanceByUserId(100);
  22. $this->assertSame(0, $value_user_3);
  23. //Access to a list of users' integral records based on type (recharge or consumption), page reading
  24. $recharge_list = Balance::getUserBalanceListByType(1, 'recharge');
  25. $this->assertSame(1, $recharge_list->count());
  26. $expend_list = Balance::getUserBalanceListByType(2, 'expend');
  27. $this->assertSame('Illuminate\Pagination\LengthAwarePaginator', get_class($expend_list));
  28. $this->assertSame(2, $expend_list->count());
  29. }
  30. }