123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- <?php
- use PHPUnit\Framework\TestCase;
- define('APP_ID', 'test');
- define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
- require_once(BASE_ROOT_PATH . '/global.php');
- require_once(BASE_CORE_PATH . '/lrlz.php');
- require_once(BASE_ROOT_PATH . '/fooder.php');
- require_once(BASE_CORE_PATH . '/framework/function/http.php');
- require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
- require_once(BASE_HELPER_PATH . '/mtopcard/mtopcard.php');
- class TestRefillPhone extends TestCase
- {
- const LocalTest = 1;
- const NetTest = 2;
- const HomeCuda = 3;
- const WorkCuda = 4;
- const CurrentTest = self::HomeCuda;
- private $mReqHost;
- private $mKey;
- private $mMchid;
- public function __construct(?string $name = null, array $data = [], $dataName = '')
- {
- parent::__construct($name, $data, $dataName);
- if (self::CurrentTest == self::LocalTest) {
- $this->mReqHost = BASE_SITE_URL;
- $this->mMchid = 1;
- $this->mKey = '1ff02223b771c0414468c8892151c602';
- }
- elseif (self::CurrentTest == self::HomeCuda) {
- $this->mReqHost = 'http://192.168.3.104';
- $this->mMchid = 1092;
- $this->mKey = '210fe406954220f56085997d6a4c5b80';
- }
- }
- public static function setUpBeforeClass() : void
- {
- Base::run_util();
- }
- private function requrl() {
- return $this->mReqHost . "/mobile/index.php";
- }
- public function testAdd()
- {
- $phone = '13911129867';
- $amount = 100;
- $url = $this->requrl();
- $order_sn = $this->make_sn();
- $order_sn = ' smsasdadad23';
- $params = ['mchid' => $this->mMchid,
- 'cardno' => $phone,
- 'amount' => $amount,
- "act" => "refill",
- "op" => "add",
- 'order_sn' => $order_sn,
- 'notifyurl' => "http://www.baidu.com"];
- $proxy = new refill_proxy($this->mKey);
- for ($i = 0; $i < 10; $i++) {
- $resp = $proxy->send($url, $params);
- Log::record("resp={$resp}", Log::DEBUG);
- }
- }
- public function testCardQuery()
- {
- $phone = '13911129867';
- // $url = "https://test.xyzshops.cn/vapi/index.php";
- $url = "https://ylapi.xyzshops.cn/vapi/index.php";
- $params = ['mchid' => $this->mMchid,
- 'cardno' => $phone,
- "act" => "card",
- "op" => "query"];
- $proxy = new refill_proxy($this->mKey);
- $resp = $proxy->send($url, $params);
- }
- private function make_sn()
- {
- return mt_rand(1000, 9999)
- . sprintf('%010d', time())
- . sprintf('%06d', (float)microtime() * 1000000);
- }
- public function testMicroTime()
- {
- [$micro,$time] = explode(' ',microtime());
- }
- }
|