TestHttp.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. public function testBase64()
  53. {
  54. $data = 'VzaryoW5iSWFZq/JyBD/wk1rW9gFxQgGwj6o2aikRRnQ3Zb/1VQ1uY37VMB9FMXg8QV3O2a+ElSxXdelNrtO6UHUwP8VMrWIYHiL9kh3w7Bhel6iBSfVAkd02pUJz433UxqNddGYllzd3DxFaySzlL5nzQwZU/8FgXX0QC3EJCuUUCPXqJnvg/sJzGXpEyt07mjGHsUusUo68HDpI+im8vb5n2SCIChABS2u5SSUF7iTtVpOPD14mc106JsEzivCBANYgwCZyDOV32nqgFmO9t4zJVI4gvUl8uya5Z9A4Q2oGrMP6DA7q14RsEBSq8sPPNDlN0AebSVnJ3krWsLTQLZ/fQgQH0diZ7oPOKEHLxdPAA9tRsIAdrdBOEAIvuuvbZiuf5a7PolcuNCJTGTgJnmOpcUpxF9tvax6ZA2X+9nFlgA1nh+Ev6wbGVwlssvQrup/PIFbVPCIVDd4jM+Vkg9y0cK/H07m+GdwytbY9dLYUzjiPXK913LZbAjL7tDfX3ELCvA10xr+CMWsM8MwrzHq5EYNIDZawke3T3rGxhi2iQ8reXx3SmJvRwg6BDQK';
  55. $y = base64_decode($data);
  56. }
  57. public function testRetparams()
  58. {
  59. $fun = function ($input) {
  60. if($input == 1) {
  61. return ['a','b',$input];
  62. }
  63. else {
  64. return ['a','b',$input,'c'];
  65. }
  66. };
  67. $val = $fun (1);
  68. if(count($val) == 3) {
  69. [$x,$y,$z] = $val;
  70. } else {
  71. [$x,$y,$z,$a] = $val;
  72. }
  73. }
  74. public function testGoods()
  75. {
  76. // $params = [ 'mchid' => 10384,
  77. // "op" => "goods",
  78. // 'act' => 'refill'
  79. // ];
  80. //$resp = $proxy->send("https://www.xyzshops.cn/mobile/index.php", $params);
  81. $params = [ 'mchid' => 10384,
  82. "op" => "goods",
  83. 'act' => 'refill'
  84. ];
  85. $proxy = new refill_proxy("682240597a865cfba5214a0c8477bd76");
  86. $resp = $proxy->send("https://ylapi.xyzshops.cn/mobile/index.php", $params);
  87. }
  88. }