mReqHost = 'http://host.docker.internal';//BASE_SITE_URL; $this->mMchid = 1; $this->mKey = '1ff02223b771c0414468c8892151c602'; } else { $this->mReqHost = 'http://121.89.212.167'; $this->mMchid = 1092; $this->mKey = '210fe406954220f56085997d6a4c5b80'; } } public static function setUpBeforeClass(): void { Base::run_util(); } public function testAddoil() { $url = $this->mReqHost . "/racc/index.php"; // $url = 'https://www.baidu.com.cn'; for ($i = 0; $i < 10; $i++) { $params = $this->make_order(); $resp = $this->send_md5($url, $params); } } public function testRequest() { $resp = http_request('https://www.baidu.com.cn'); } private function make_order() { $notifyurl = 'https://www.xyzshops.cn/mobile/signature.php'; $params = ['mchid' => $this->mMchid, 'cardno' => '13911129867', 'amount' => "30", "act" => "refill", "op" => "add", 'order_sn' => $this->make_sn(), 'notifyurl' => $notifyurl]; return $params; } private function send_md5($url, $params) { $body = $this->body($params); $body .= "&key={$this->mKey}"; $params['sign'] = md5($body); $resp = http_request($url, $params); Log::record("resp:{$resp}", Log::DEBUG); return $resp; } private function body($params) { ksort($params); $body = ""; $i = 0; foreach ($params as $k => $v) { if (false === $this->checkEmpty($v) && "@" != substr($v, 0, 1)) { if ($i == 0) { $body .= "{$k}" . "=" . urlencode($v); } else { $body .= "&" . "{$k}" . "=" . urlencode($v); } $i++; } } return $body; } private function checkEmpty($value) { if (!isset($value)) return true; if ($value === null) return true; if (trim($value) === "") return true; return false; } public function testFactory() { $providers = refill\RefillFactory::instance(); } private function make_sn() { return mt_rand(1000, 9999) . sprintf('%010d', time()) . sprintf('%06d', (float)microtime() * 1000000); } } //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testLoadBlack)( .*)?$/" --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