KFMessageControllerTest.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. 'id' => 4
  33. ]);
  34. $this->dumpJson($res);
  35. }
  36. public function testupdateContent()
  37. {
  38. $res = $this->withHeaders([
  39. 'Authorization' => 'Bearer '. $this->token,
  40. ])->json('post','http://localhost/api/wechatPlatform/kfMessage/updateContent', [
  41. 'id' => 4,
  42. 'name' => 'change-'.uniqid(),
  43. 'message_type' => 1,
  44. 'message_content' => [
  45. ['text' => 'changexxxx']
  46. ],
  47. 'u_type' => 2,
  48. 'uc_unique_key' => uniqid('',true),
  49. 'send_at' => date('Y-m-d H:i:s', strtotime('+2 hour'))
  50. ]);
  51. $this->dumpJson($res);
  52. }
  53. public function testupdateGZH()
  54. {
  55. $res = $this->withHeaders([
  56. 'Authorization' => 'Bearer '. $this->token,
  57. ])->json('post','http://localhost/api/wechatPlatform/kfMessage/updateGZH', [
  58. 'id' => 4,
  59. 'gzh_ids' => []
  60. ]);
  61. $this->dumpJson($res);
  62. }
  63. public function teststop()
  64. {
  65. $res = $this->withHeaders([
  66. 'Authorization' => 'Bearer '. $this->token,
  67. ])->json('post','http://localhost/api/wechatPlatform/kfMessage/stop', [
  68. 'id' => 3
  69. ]);
  70. $this->dumpJson($res);
  71. }
  72. public function testdelete()
  73. {
  74. $res = $this->withHeaders([
  75. 'Authorization' => 'Bearer '. $this->token,
  76. ])->json('post','http://localhost/api/wechatPlatform/kfMessage/delete', [
  77. 'id' => 3
  78. ]);
  79. $this->dumpJson($res);
  80. }
  81. }