TestHttp.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. define('APP_ID', 'test');
  4. define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
  5. require_once(BASE_ROOT_PATH . '/global.php');
  6. require_once(BASE_CORE_PATH . '/lrlz.php');
  7. require_once(BASE_ROOT_PATH . '/fooder.php');
  8. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  9. require_once(BASE_HELPER_PATH . '/refill_proxy.php');
  10. class TestHttp extends TestCase
  11. {
  12. public static function setUpBeforeClass(): void
  13. {
  14. Base::run_util();
  15. }
  16. public function testRequest()
  17. {
  18. Log::record(__METHOD__,Log::DEBUG);
  19. for ($i = 0; $i < 10000; $i++) {
  20. $rsp = http_request("https://test.xyzshops.cn");
  21. }
  22. }
  23. public function testIPS()
  24. {
  25. $ins = Cache::getInstance('cacheredis');
  26. $ins->hdel('', '', '');
  27. $x = 'a:2:{i:0;s:14:"222.129.49.232";i:1;s:14:"222.129.55.246";}';
  28. $x = unserialize($x);
  29. $x[] = '';
  30. }
  31. public function testRefillAdd()
  32. {
  33. $time = time() * 10;
  34. for ($i = 0;$i < 2; $i++) {
  35. $this->push_order(1092, $time, $i);
  36. }
  37. }
  38. private function push_order($mchid,$time,$index)
  39. {
  40. $notify_url = "https://test.xyzshops.cn/mobile/callback/bridge_test.php";
  41. $params = [ 'mchid' => $mchid,
  42. 'amount' => 30,
  43. 'order_sn' => "{$time}" . sprintf("%'010d",$index),
  44. 'cardno' => '13911129867',
  45. "act" => "refill",
  46. "op" => "add",
  47. 'notifyurl' => $notify_url
  48. ];
  49. $proxy = new refill_proxy("210fe406954220f56085997d6a4c5b80");
  50. $resp = $proxy->send("https://test.xyzshops.cn/mobile/index.php", $params);
  51. }
  52. }