<?php

namespace Tests\Callback\Http\Controllers;

use Modules\Callback\Http\Controllers\JuliangAccountController;
use PHPUnit\Framework\TestCase;
use Tests\UsedTestCase;

class JuliangAccountControllerTest extends UsedTestCase
{

    public function testAddAccount()
    {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('post','http://localhost/api/callback/juliangAccount/addAccount', [
            'account_id' => 123456810,
            'account_name' => 'jkljlkj-10',
            'state' => 1,
            'protect_num' => 3,
            'default_rate' => 50,
            'rate_time_config' => [
                ['start_time' => '00:35', 'end_time' => '12:34', 'config_per' => 20],
                ['start_time' => '13:39', 'end_time' => '19:34', 'config_per' => 30],
            ],
            'min_money' => 20,
            'max_money' => 50,
            'callback_state' => 1
        ]);

        $res->dump();
    }

    public function testupdateCallbackConfig() {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('post','http://localhost/api/callback/juliangAccount/updateCallbackConfig', [
            'ids' => [4],
            'state' => 1,
            'protect_num' => 3,
            'default_rate' => 30,
            'rate_time_config' => [
                ['start_time' => '15:00', 'end_time' => '16:10', 'config_per' => 20],
                ['start_time' => '16:20', 'end_time' => '17:30', 'config_per' => 50],
                ['start_time' => '17:55', 'end_time' => '18:30', 'config_per' => 20],
            ],
            'min_money' => 30,
            'max_money' => 80,
        ]);
        $res->dump();
    }
    public function testList() {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('get','http://localhost/api/callback/juliangAccount/list');

        $res->dump();
        $this->dumpJson($res);
    }

    public function testturnCallbackState() {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('post','http://localhost/api/callback/juliangAccount/turnCallbackState', [
            'id' => 5,
            'state' => 1
        ]);
        $res->dump();
    }

    public function testunbindPromotion() {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('post','http://localhost/api/callback/juliangAccount/unbindPromotion', [
            'id' => 5,
        ]);
        $res->dump();
    }
}