sign($params); return $params; } public function sign($params) { $body = $this->body($params); $body .= Gftd::APP_SECRET; return md5($body); } protected function check_empty($value) { if (!isset($value)) return true; if ($value === null) return true; if (trim($value) === "") return true; return false; } private function body($params) { ksort($params); $body = ""; $i = 0; foreach ($params as $k => $v) { if (false === $this->check_empty($v) && "@" != substr($v, 0, 1)) { if ($i == 0) { $body .= "{$k}" . "=" . $v; } else { $body .= "&" . "{$k}" . "=" . $v; } $i++; } } return $body; } } class TestRefillCancel extends TestCase { private $mReqHost; private $mKey; private $mMchid; public function __construct(?string $name = null, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); if (CurrentTest == LocalTest) { $this->mReqHost = BASE_SITE_URL; $this->mMchid = 1; $this->mKey = '1ff02223b771c0414468c8892151c602'; } else { $this->mReqHost = 'https://www.xyzshops.cn'; $this->mMchid = 1092; $this->mKey = '210fe406954220f56085997d6a4c5b80'; } } public function testGFTDCancel() { $params['channelOrderNumber'] = '930664641391799632'; $params['orderNumber'] = 'GYFL1611297392856576'; $params['message'] = '只能给绑定正确手机号的油卡充值或只能给主卡充值'; $params['status'] = 109; $prov = new Gftd(); $result = $prov->params($params); $resp = http_post_data("https://www.xyzshops.cn/mobile/refill_gftd.php",json_encode($result,JSON_UNESCAPED_UNICODE),config::ExtHeaders); Log::record($resp,Log::DEBUG); } public function testGFTDSuccess() { #{"channelOrderNumber":"750664483985964632", #"orderNumber":"GYFL1611139986728407", #"message":"充值成功", #"signature":"f0eec4d0ccc1a0b6ec06003a648fd9b4", #"voucher":"2421012018536345", #"status":101} $params['channelOrderNumber'] = '950664986520404793'; $params['orderNumber'] = 'GYFL1611642520980625'; $params['message'] = '充值成功'; $params['status'] = 101; $params["voucher"] = "2421012614280402"; $prov = new Gftd(); $result = $prov->params($params); $resp = http_post_data("https://www.xyzshops.cn/mobile/refill_gftd.php",json_encode($result,JSON_UNESCAPED_UNICODE),config::ExtHeaders); Log::record($resp,Log::DEBUG); } public function testBuildQuery() { $post = function () { $data = [ 'appKey' => '2023434', 'number' => '1231232', 'orderId' => '2324', 'mobile' => '2343244', 'reason' => '', 'amount' => 100, 'actualAmount' => 100, 'createdAt' => '2134r32', 'status' => 'WAIT', ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_VERBOSE, true); curl_setopt($ch, CURLOPT_FORBID_REUSE, 1); curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch , CURLOPT_POSTFIELDS, $data); curl_setopt($ch , CURLOPT_URL, 'http://192.168.1.220/mobile/signature.php'); $response = curl_exec($ch); curl_close( $ch ); return $response; }; $x = $post(); } } //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCall)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test //docker-compose -f ./docker-compose-dev.yml run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCall)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test