TestQueue.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php declare(strict_types=1);
  2. use PHPUnit\Framework\TestCase;
  3. /**
  4. * Created by PhpStorm.
  5. * User: stanley-king
  6. * Date: 16/7/20
  7. * Time: 下午4:16
  8. */
  9. define('BASE_ROOT_PATH',str_replace('/test','',dirname(__FILE__)));
  10. require_once(BASE_ROOT_PATH . '/global.php');
  11. require_once(BASE_CORE_PATH . '/lrlz.php');
  12. require_once(BASE_ROOT_PATH . '/fooder.php');
  13. class testQueue extends TestCase
  14. {
  15. public static function setUpBeforeClass() :void
  16. {
  17. Base::run_util();
  18. }
  19. public function testQueueSrv()
  20. {
  21. if (ob_get_level()) ob_end_clean();
  22. $model_queue = Model('queue',BASE_PATH);
  23. $worker = new QueueServer();
  24. while (true)
  25. {
  26. $list_key = $worker->scan();
  27. if (!empty($list_key) && is_array($list_key))
  28. {
  29. foreach ($list_key as $key) {
  30. $content = $worker->pop($list_key, 0);
  31. if (empty($content)) continue;
  32. $method = key($content);
  33. $arg = current($content);
  34. // $model_queue->$method($arg);
  35. echo date('Y-m-d H:i:s',time()).' '.$method."\n";
  36. flush();
  37. ob_flush();
  38. }
  39. }
  40. sleep(1);
  41. }
  42. }
  43. public function testPush()
  44. {
  45. //{"action":"sendreq","params":null}
  46. $x['action'] = 'sendreq';
  47. $x['params'] = ['speed' => 30];
  48. $y = json_encode($x);
  49. $param['member_id'] = 36490;
  50. $param['text'] = "红包退还通知:您发送的红包已超过24小时,退还未被领取的金额1234元,请在收支明细中查看.";
  51. $param['go_type'] = '';
  52. QueueClient::push('upushSendMsg',$param);
  53. }
  54. public function testOrderSuccess()
  55. {
  56. $mod = Model('order');
  57. $pay_sn = '270563196360813623';
  58. $order_info = $mod->getOrderInfo(array('pay_sn' => $pay_sn));
  59. $logic_order = Logic('order');
  60. $result = $logic_order->changeOrderStateReceive($order_info,'system','系统','超期未收货系统自动完成订单');
  61. }
  62. public function testRefund()
  63. {
  64. $client = Logic('queue');
  65. $client->QueryRefund(['order_id' => 1140016194]);
  66. }
  67. }