<?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', [
        ]);
        $this->dumpJson($res);
    }

    public function testupdateContent()
    {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('get','http://localhost/api/wechatPlatform/kfMessage/list', [
        ]);
        $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);
    }
}
