56 lines
1.7 KiB
PHP
56 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use App\Utils\API\Rocketgo;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* 测试用户提现类
|
|
*/
|
|
class TestUserWithdraw extends TestCase
|
|
{
|
|
/**
|
|
* 存放用户登录token
|
|
*
|
|
* @var [type]
|
|
*/
|
|
private static $UserToken = null;
|
|
|
|
|
|
/**
|
|
* 测试用户登录功能
|
|
*
|
|
*/
|
|
public function testUserLogin()
|
|
{
|
|
$data = ['username' => '01930044627', 'password' => 'cCqQgG9koky^#uDFXllNUM46@jrI7KfsL77IIWwt'];
|
|
$res = HttpBase::httpclient($data, '/api/user/login', 'POST', null, 'form');
|
|
$token = $res['data']['userinfo']['token'];
|
|
$this->assertArrayHasKey('data', $res, "返回的数据应包含 'data' 键");
|
|
$this->assertArrayHasKey('userinfo', $res['data'], "返回的数据应包含 'userinfo' 键");
|
|
$this->assertArrayHasKey('token', $res['data']['userinfo'], "返回的 'userinfo' 应包含 'token' 键");
|
|
$this->assertNotEmpty($token, "token 应该是非空的");
|
|
// var_dump($res['data']['userinfo']['token']);
|
|
self::$UserToken = $token;
|
|
return $token;
|
|
}
|
|
/**
|
|
* 测试用户提款
|
|
* 依赖于 testUserLogin() 测试方法
|
|
*
|
|
* @depends testUserLogin
|
|
*/
|
|
public function testWithdrawSubmit($token)
|
|
{
|
|
$data = ['money' => '4500', 'bank_id' => '2923'];
|
|
$res = HttpBase::httpclient($data, '/api/withdraw/submit', 'POST', null, 'form',$token);
|
|
var_dump($res);
|
|
$res = HttpBase::httpclient($data, '/api/withdraw/submit', 'POST', null, 'form',$token);
|
|
var_dump($res);
|
|
$res = HttpBase::httpclient($data, '/api/withdraw/submit', 'POST', null, 'form',$token);
|
|
var_dump($res);
|
|
|
|
}
|
|
}
|