12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- namespace Tests\WechatPlatform\Http;
- use Modules\WechatPlatform\Http\Controllers\KFMessageController;
- use PHPUnit\Framework\TestCase;
- use Tests\UsedTestCase;
- class KFMessageControllerTest extends UsedTestCase
- {
- public function testAdd()
- {
- $STR = <<<AAA
- 文本内容<a href="http://www.qq.com" data-miniprogram-appid="appid" data-miniprogram-path="pages/index/index">点击跳小程序</a>
- AAA;
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('post','http://localhost/api/wechatPlatform/kfMessage/add', [
- 'name' => 'liuzj-test-'. uniqid(),
- 'send_at' => date('Y-m-d H:i:s', strtotime('tomorrow')),
- 'message_type' => 1,
- 'u_type' => 1,
- 'message_content' => [
- ['text' => '普通文本👌🏻'],
- ['text' => $STR]
- ]
- ]);
- $this->dumpJson($res);
- }
- public function testList()
- {
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('get','http://localhost/api/wechatPlatform/kfMessage/list', [
- 'id' => 4
- ]);
- $this->dumpJson($res);
- }
- public function testupdateContent()
- {
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('post','http://localhost/api/wechatPlatform/kfMessage/updateContent', [
- 'id' => 4,
- 'name' => 'change-'.uniqid(),
- 'message_type' => 1,
- 'message_content' => [
- ['text' => 'changexxxx']
- ],
- 'u_type' => 2,
- 'uc_unique_key' => uniqid('',true),
- 'send_at' => date('Y-m-d H:i:s', strtotime('+2 hour'))
- ]);
- $this->dumpJson($res);
- }
- public function testupdateGZH()
- {
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('post','http://localhost/api/wechatPlatform/kfMessage/updateGZH', [
- 'id' => 4,
- 'gzh_ids' => []
- ]);
- $this->dumpJson($res);
- }
- public function teststop()
- {
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('post','http://localhost/api/wechatPlatform/kfMessage/stop', [
- 'id' => 3
- ]);
- $this->dumpJson($res);
- }
- public function testdelete()
- {
- $res = $this->withHeaders([
- 'Authorization' => 'Bearer '. $this->token,
- ])->json('post','http://localhost/api/wechatPlatform/kfMessage/delete', [
- 'id' => 3
- ]);
- $this->dumpJson($res);
- }
- }
|