KFMessageControllerTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace Tests\WechatPlatform\Http;
  3. use Modules\WechatPlatform\Http\Controllers\KFMessageController;
  4. use PHPUnit\Framework\TestCase;
  5. use Tests\UsedTestCase;
  6. class KFMessageControllerTest extends UsedTestCase
  7. {
  8. public function testAdd()
  9. {
  10. $STR = <<<AAA
  11. 文本内容<a href="http://www.qq.com" data-miniprogram-appid="appid" data-miniprogram-path="pages/index/index">点击跳小程序</a>
  12. AAA;
  13. $res = $this->withHeaders([
  14. 'Authorization' => 'Bearer '. $this->token,
  15. ])->json('post','http://localhost/api/wechatPlatform/kfMessage/add', [
  16. 'name' => 'liuzj-test-'. uniqid(),
  17. 'send_at' => date('Y-m-d H:i:s', strtotime('tomorrow')),
  18. 'message_type' => 1,
  19. 'u_type' => 1,
  20. 'message_content' => [
  21. ['text' => '普通文本👌🏻'],
  22. ['text' => $STR]
  23. ]
  24. ]);
  25. $this->dumpJson($res);
  26. }
  27. public function testList()
  28. {
  29. $res = $this->withHeaders([
  30. 'Authorization' => 'Bearer '. $this->token,
  31. ])->json('get','http://localhost/api/wechatPlatform/kfMessage/list', [
  32. ]);
  33. $this->dumpJson($res);
  34. }
  35. public function testupdateContent()
  36. {
  37. $res = $this->withHeaders([
  38. 'Authorization' => 'Bearer '. $this->token,
  39. ])->json('get','http://localhost/api/wechatPlatform/kfMessage/list', [
  40. ]);
  41. $this->dumpJson($res);
  42. }
  43. public function teststop()
  44. {
  45. $res = $this->withHeaders([
  46. 'Authorization' => 'Bearer '. $this->token,
  47. ])->json('post','http://localhost/api/wechatPlatform/kfMessage/stop', [
  48. 'id' => 3
  49. ]);
  50. $this->dumpJson($res);
  51. }
  52. public function testdelete()
  53. {
  54. $res = $this->withHeaders([
  55. 'Authorization' => 'Bearer '. $this->token,
  56. ])->json('post','http://localhost/api/wechatPlatform/kfMessage/delete', [
  57. 'id' => 3
  58. ]);
  59. $this->dumpJson($res);
  60. }
  61. }