123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <?php
- declare(strict_types=1);
- 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_HELPER_PATH . '/queue/rdispatcher.php');
- require_once(BASE_HELPER_PATH . '/refill/RefillFactory.php');
- require_once(BASE_CORE_PATH . '/framework/function/http.php');
- use PHPUnit\Framework\TestCase;
- const LocalTest = 1;
- const NetTest = 2;
- const CurrentTest = LocalTest;
- class TestDispatcher extends TestCase
- {
- private $mMchid;
- public static function setUpBeforeClass() : void
- {
- Base::run_util();
- }
- public function __construct(?string $name = null, array $data = [], $dataName = '')
- {
- parent::__construct($name, $data, $dataName);
- if (CurrentTest == LocalTest) {
- $this->mMchid = 1;
- } else {
- $this->mMchid = 1092;
- }
- }
- public function testPushMessage()
- {
- foreach (range(1,2000,1) as $i) {
- queue\DispatcherClient::instance()->push('xxx',$i);
- }
- }
- public function testAdd()
- {
- foreach (range(1,2000,1) as $i) {
- queue\DispatcherClient::instance()->push('add',[]);
- }
- }
- public function testAddoil()
- {
- foreach (range(1,1,1) as $i) {
- queue\DispatcherClient::instance()->push('add',$this->make_order());
- }
- }
- private function make_order()
- {
- $mchid = $this->mMchid;
- $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
- $buyer_id = intval($mchinfo['admin_id']);
- $params = [ 'mchid' => $this->mMchid,
- 'buyer_id' => $buyer_id,
- 'amount' => 50,
- 'card_no' => 13911129867,
- 'mch_order' => $this->make_sn(),
- 'notify_url' => 'https://www.xyzshops.cn/mobile/signature.php'];
- return $params;
- }
- private function make_sn()
- {
- return mt_rand(1000, 9999)
- . sprintf('%010d', time())
- . sprintf('%06d', (float)microtime() * 1000000);
- }
- public function testCurl()
- {
- Swoole\Coroutine\run(function () {
- $curl = curl_init();
- var_dump($curl, (int) $curl);
- //resource(4) of type (Swoole-Coroutine-cURL Handle)
- //int(4)
- $resp = http_request('https://www.xyzshops.cn/mobile/index.php?act=index&op=index&client_type=ios');
- Log::record("recv size=" . strlen($resp), Log::DEBUG);
- });
- }
- public function testDefine()
- {
- $x = MASTER_DBHOST . 'xxx';
- }
- }
|