TestRefillYl.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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/RefillFactory.php');
  10. require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
  11. const LocalTest = 1;
  12. const NetTest = 2;
  13. const CurrentTest = NetTest;
  14. class TestRefillYl extends TestCase
  15. {
  16. public static function setUpBeforeClass(): void
  17. {
  18. Base::run_util();
  19. refill\RefillFactory::instance();
  20. }
  21. private function getProvider($name,$type = 'RefillPhone')
  22. {
  23. $file = BASE_HELPER_RAPI_PATH . "/$name/{$type}.php";
  24. if(!file_exists($file)){
  25. Log::record("provider api file={$file} not exist.",Log::DEBUG);
  26. return false;
  27. } else {
  28. require_once($file);
  29. Log::record("file={$file} load success.",Log::DEBUG);
  30. }
  31. $class_name = "refill\\{$name}\\{$type}";
  32. if (class_exists($class_name, false)) {
  33. $caller = new $class_name([]);
  34. return $caller;
  35. } else {
  36. $error = "Base Error: class {$class_name} isn't exists!";
  37. Log::record($error, Log::ERR);
  38. return false;
  39. }
  40. }
  41. private function make_sn()
  42. {
  43. return mt_rand(1000, 9999)
  44. . sprintf('%010d', time())
  45. . sprintf('%06d', (float)microtime() * 1000000);
  46. }
  47. public function testYamiao_high()
  48. {
  49. // $provider = $this->getProvider('yamiao_high');
  50. // $resp = $provider->balance();
  51. // $resp = $provider->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  52. // $resp = $provider->query(['order_sn' => '80031648092448376229']);
  53. $body = '{"orderId":"220324112752228331","appId":"ILo9IfHYg0","outOrderId":"80031648092448376229","sign":"1ef1ba02308669673ebcb136cb67e1c1","orderStatus":"3","completeTime":"20220324112803","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
  54. $params = json_decode($body, true);
  55. $provider = $this->getProvider('yamiao_high','RefillCallBack');
  56. $ret = $provider->verify($params);
  57. $resp = $provider->notify($params);
  58. }
  59. public function testYamiao_normal()
  60. {
  61. // $provider = $this->getProvider('yamiao_normal');
  62. // $resp = $provider->balance();
  63. // $resp = $provider->add(13699279618, 4, 30, ['order_sn' => $this->make_sn()]);
  64. // $resp = $provider->query(['order_sn' => '65931648092912669252']);
  65. $body = '{"orderId":"220324113519231696","appId":"Mxh2JUZocr","outOrderId":"65931648092912669252","sign":"6560cab5e7ec5f265b04632c4c2a1f1a","orderStatus":"3","completeTime":"20220324113522","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
  66. $params = json_decode($body, true);
  67. $provider = $this->getProvider('yamiao_normal','RefillCallBack');
  68. $ret = $provider->verify($params);
  69. $resp = $provider->notify($params);
  70. }
  71. public function testYamiaoman()
  72. {
  73. $provider = $this->getProvider('yamiaoman');
  74. $resp = $provider->balance();
  75. // $resp = $provider->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  76. // $resp = $provider->query(['order_sn' => '53351647242979116742']);
  77. // $body = '{"orderId":"220314152954756093","appId":"zIODZmzSCk","outOrderId":"53351647242979116742","sign":"41ad7d4b4b26559377c6443d2b0d6c68","orderStatus":"3","completeTime":"20220314172722","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
  78. // $params = json_decode($body, true);
  79. // $provider = $this->getProvider('yamiaoman','RefillCallBack');
  80. // $ret = $provider->verify($params);
  81. // $resp = $provider->notify($params);
  82. }
  83. public function testGuantu()
  84. {
  85. // $provider = $this->getProvider('guantu');
  86. // $resp = $provider->balance();
  87. // $resp = $provider->add(18500608333, 5, 30, ['order_sn' => $this->make_sn()]);
  88. // $resp = $provider->query(['order_sn' => '59041648111767968756']);
  89. $body = ' {"orderId":"220324164934076577","appId":"t7gmui2D3w","outOrderId":"59041648111767968756","sign":"e957df33cfaa777cd3c2349cd2023996","orderStatus":"3","completeTime":"20220324165033","orderDesc":"\u8ba2\u5355\u5931\u8d25"}';
  90. $params = json_decode($body, true);
  91. $provider = $this->getProvider('guantu','RefillCallBack');
  92. $ret = $provider->verify($params);
  93. $resp = $provider->notify($params);
  94. }
  95. public function testLechong()
  96. {
  97. $provider = $this->getProvider('lechong');
  98. // $resp = $provider->balance();
  99. // $resp = $provider->add(18500608333, 5, 50, ['order_sn' => $this->make_sn()]);
  100. // $resp = $provider->query(['order_sn' => '65361648114672703928']);
  101. $body = '{"sellerid":"65361648114672703928","agentcode":"202203241556","account":"MTg1MDA2MDgzMzM=","value":"50","payvalue":"47.8000","voucher":"","createtime":"20220324173803","endtime":"20220324173857","state":"4","remark":"","time":"20220324174224","sign":"8a2c011095cadb6dc5abd00c25a11d1c"}';
  102. $params = json_decode($body, true);
  103. $provider = $this->getProvider('lechong','RefillCallBack');
  104. $ret = $provider->verify($params);
  105. $resp = $provider->notify($params);
  106. }
  107. }