TestAccRefill.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. use PHPUnit\Framework\TestCase;
  3. use const mtopcard\SinopecCard;
  4. define('APP_ID', 'test');
  5. define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
  6. require_once(BASE_ROOT_PATH . '/global.php');
  7. require_once(BASE_CORE_PATH . '/lrlz.php');
  8. require_once(BASE_ROOT_PATH . '/fooder.php');
  9. require_once(BASE_CORE_PATH . '/framework/function/http.php');
  10. require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
  11. require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
  12. const LocalTest = 1;
  13. const NetTest = 2;
  14. const CurrentTest = NetTest;
  15. class TestAccRefill extends TestCase
  16. {
  17. private $mReqHost;
  18. private $mKey;
  19. private $mMchid;
  20. public function __construct(?string $name = null, array $data = [], $dataName = '')
  21. {
  22. parent::__construct($name, $data, $dataName);
  23. if (CurrentTest == LocalTest) {
  24. $this->mReqHost = BASE_SITE_URL;
  25. $this->mMchid = 1;
  26. $this->mKey = '1ff02223b771c0414468c8892151c602';
  27. } else {
  28. $this->mReqHost = 'http://121.89.212.167';
  29. $this->mMchid = 1092;
  30. $this->mKey = '210fe406954220f56085997d6a4c5b80';
  31. }
  32. }
  33. public static function setUpBeforeClass(): void
  34. {
  35. Base::run_util();
  36. }
  37. public function testAddoil()
  38. {
  39. $url = $this->mReqHost . "/racc/index.php";
  40. for ($i = 0; $i < 10000; $i++)
  41. {
  42. $params = $this->make_order();
  43. $resp = $this->send_md5($url, $params);
  44. Log::record($resp, Log::DEBUG);
  45. }
  46. }
  47. private function make_order()
  48. {
  49. $notifyurl = 'https://www.xyzshops.cn/mobile/signature.php';
  50. $params = ['mchid' => $this->mMchid,
  51. 'cardno' => '1000111100020445281',
  52. 'amount' => "100",
  53. "act" => "refill",
  54. "op" => "add",
  55. 'order_sn' => $this->make_sn(),
  56. 'notifyurl' => $notifyurl];
  57. return $params;
  58. }
  59. public function testFactory()
  60. {
  61. $providers = refill\RefillFactory::instance();
  62. }
  63. private function make_sn()
  64. {
  65. return mt_rand(1000, 9999)
  66. . sprintf('%010d', time())
  67. . sprintf('%06d', (float)microtime() * 1000000);
  68. }
  69. }
  70. //docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testLoadBlack)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test
  71. //docker-compose -f ./docker-compose-dev.yml run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestRefill::testCall)( .*)?$/" --test-suffix TestRefill.php /var/www/html/test