TestElectric.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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://www.xyzshops.cn' . '/mobile/innercb.php',
  29. 'cardno' => '1004638637',
  30. 'amount' => 200,
  31. 'company_type' => 'nation',
  32. 'use_type' => 'home',
  33. 'card_id' => '051818',
  34. 'province' => 1,
  35. 'city' => '北京市'
  36. ];
  37. $proxy = new refill_proxy('210fe406954220f56085997d6a4c5b80');
  38. // $proxy->send(BASE_SITE_URL . "/mobile/index.php",$params);
  39. $proxy->send('https://www.xyzshops.cn' . "/mobile/index.php",$params);
  40. }
  41. public function testNet()
  42. {
  43. $params = [ 'mchid' => 1092,
  44. "act" => "refill",
  45. "op" => "add_electric",
  46. 'order_sn' => $this->make_sn(),
  47. 'notifyurl' => 'https://www.xyzshops.cn/mobile/signature.php',
  48. 'cardno' => '1004638637',
  49. 'amount' => 100,
  50. 'company_type' => 'south',
  51. 'use_type' => 'home',
  52. 'card_id' => '051818',
  53. 'province' => 1
  54. ];
  55. $x = http_request(BASE_SITE_URL . "/mobile/index.php",$params);
  56. }
  57. public function testSinopec_coupon()
  58. {
  59. $params = [ 'mchid' => 1092,
  60. "act" => "refill",
  61. "op" => "add_sinopec_coupon",
  62. 'order_sn' => $this->make_sn(),
  63. 'notifyurl' => 'https://www.xyzshops.cn/mobile/signature.php',
  64. 'cardno' => '13699279618',
  65. 'amount' => 5,
  66. 'province' => 19
  67. ];
  68. $proxy = new refill_proxy('210fe406954220f56085997d6a4c5b80');
  69. $proxy->send('https://www.xyzshops.cn' . "/mobile/index.php",$params);
  70. }
  71. private function make_sn()
  72. {
  73. return mt_rand(1000, 9999)
  74. . sprintf('%010d', time())
  75. . sprintf('%06d', (float)microtime() * 1000000);
  76. }
  77. }