123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <?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 testNotify()
- {
- $logic = Logic('queue');
- $logic->NotifyMerchantComplete(['order_id' => 6462,'manual' => true]);
- }
- public function testAddoil()
- {
- foreach (range(1,2000,1) as $i) {
- queue\DispatcherClient::instance()->push('add',$this->make_order());
- }
- }
- public function testAddO()
- {
- foreach (range(1,1,1) as $i) {
- queue\DispatcherClient::instance()->push('add',$this->make_order());
- }
- }
- public function testAddH()
- {
- foreach (range(1,50000,1) as $i) {
- queue\DispatcherClient::instance()->push('add',$this->make_order());
- }
- }
- public function testGoods()
- {
- $goods = refill\RefillFactory::instance()->goods();
- $result = [];
- foreach ($goods as $type => $specs)
- {
- if($type == mtopcard\SinopecCard || $type == mtopcard\PetroChinaCard) {
- foreach ($specs as $spec) {
- $result['oil_amount'][] = $spec;
- }
- }
- else {
- $result['phone_amount'][] = $spec;
- }
- }
- return $result;
- }
- private function make_order()
- {
- $mchid = 1092;//
- // $mchid = $this->mMchid;
- $mchinfo = Model('merchant')->getMerchantInfo(['mchid' => $mchid]);
- $buyer_id = intval($mchinfo['admin_id']);
- $params = [ 'mchid' => $mchid,
- 'buyer_id' => $buyer_id,
- 'amount' => 100,
- 'card_no' => 15120035568,
- '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';
- }
- public function testPolicy()
- {
- $key = "common_phone_speed_";
- }
- }
|