TcTest.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace App\Module\Fund\Tests\Unit;
  3. use App\Module\Fund\Dto\TransferDto;
  4. use App\Module\Fund\Enums\FUND_TYPE;
  5. use App\Module\Fund\Services\AccountService;
  6. use App\Module\Fund\Services\DtoService;
  7. use App\Module\Fund\Services\FundService;
  8. use App\Module\Fund\Models\FundModel;
  9. use Illuminate\Support\Facades\DB;
  10. use Tests\TestCase;
  11. /**
  12. * 流转测试
  13. */
  14. class TcTest extends TestCase
  15. {
  16. protected $fromUserId = 10002;
  17. public function setUp(): void
  18. {
  19. parent::setUp();
  20. AccountService::check4user($this->fromUserId);
  21. // 确保测试账户有足够余额
  22. $fund = new FundService($this->fromUserId, FUND_TYPE::BNB->value);
  23. if ($fund->balance() < 10000000) {
  24. $fund->admin_operate(1, FUND_TYPE::BNB, 1000000000, 'TEST');
  25. }
  26. }
  27. /**
  28. * 测试转账DTO
  29. */
  30. public function test_dto()
  31. {
  32. DB::beginTransaction();
  33. $fund = new FundService($this->fromUserId, 401);
  34. $res = $fund->circulation(FUND_TYPE::BNB, 10000000, 1, 'TEST', 'TEST');
  35. self::assertTrue($res);
  36. DB::commit();
  37. }
  38. }