TestElectric.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_HELPER_PATH . '/mtopcard/mtopcard.php');
  9. require_once(BASE_HELPER_PATH . '/refill_proxy.php');
  10. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  11. class TestElectric extends TestCase
  12. {
  13. public static function setUpBeforeClass() : void
  14. {
  15. Base::run_util();
  16. }
  17. public function testCardid()
  18. {
  19. $card_id = '051818';
  20. $succ = mtopcard\is_alpha($card_id);
  21. }
  22. public function testAddElectric()
  23. {
  24. $params = [ 'mchid' => 1092,
  25. "act" => "refill",
  26. "op" => "add_electric",
  27. 'order_sn' => $this->make_sn(),
  28. 'notifyurl' => 'https://test.xyzshops.cn' . '/mobile/innercb.php',
  29. 'cardno' => '1004638637',
  30. 'amount' => 50,
  31. 'company_type' => 'nation',
  32. 'use_type' => 'home',
  33. 'card_id' => '051818',
  34. 'province' => 1
  35. ];
  36. $proxy = new refill_proxy('210fe406954220f56085997d6a4c5b80');
  37. // $proxy->send(BASE_SITE_URL . "/mobile/index.php",$params);
  38. $proxy->send('https://test.xyzshops.cn' . "/mobile/index.php",$params);
  39. }
  40. public function testNet()
  41. {
  42. $params = [ 'mchid' => 1092,
  43. "act" => "refill",
  44. "op" => "add_electric",
  45. 'order_sn' => $this->make_sn(),
  46. 'notifyurl' => 'https://www.xyzshops.cn/mobile/signature.php',
  47. 'cardno' => '1004638637',
  48. 'amount' => 100,
  49. 'company_type' => 'south',
  50. 'use_type' => 'home',
  51. 'card_id' => '051818',
  52. 'province' => 1
  53. ];
  54. $x = http_request(BASE_SITE_URL . "/mobile/index.php",$params);
  55. }
  56. private function make_sn()
  57. {
  58. return mt_rand(1000, 9999)
  59. . sprintf('%010d', time())
  60. . sprintf('%06d', (float)microtime() * 1000000);
  61. }
  62. }