<?php

namespace Tests\Callback\Http\Controllers\JLEvent;

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

class JLEventControllerTest extends UsedTestCase
{

    public function testAdd()
    {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('post','http://localhost/api/callback/jlEvent/add', [
            'name' => 'liuzj-test-'.rand(1, 100000),
            'is_roi' => 2,
            'charge_type' => 1,
            'charge_money_map' => [
                ['min_money' => 10, 'max_money' => 20, 'callback_type' => 3, 'callback_param' => '1:3'],
                ['min_money' => 20, 'max_money' => 25, 'callback_type' => 2, 'callback_param' => ''],
                ['min_money' => 25, 'max_money' => 30, 'callback_type' => 2, 'callback_param' => ''],
            ]
        ]);

        $this->dumpJson($res);
    }

    public function testUpdate()
    {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('post','http://localhost/api/callback/jlEvent/update', [
            'ids' => [5, 6],
            'name' => 'liuzj-test-'.rand(1, 100000),
            'is_roi' => 1,
            'charge_type' => 1,
            'charge_money_map' => [
                ['min_money' => 10, 'max_money' => 20, 'callback_type' => 1, 'callback_param' => ''],
//                ['min_money' => 20, 'max_money' => 25, 'callback_type' => 2, 'callback_param' => ''],
                ['min_money' => 25, 'max_money' => 30, 'callback_type' => 2, 'callback_param' => ''],
                ['min_money' => 55, 'max_money' => 70, 'callback_type' => 3, 'callback_param' => '1:5'],
            ]
        ]);

        $this->dumpJson($res);
    }

    public function testList()
    {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('get','http://localhost/api/callback/jlEvent/list', [
            'id' => 5,
//            'name' => 'liuzj',
//        'promotion_id' => 21
        ]);

        $this->dumpJson($res);
    }
    public function testlistCustomRate()
    {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('get','http://localhost/api/callback/jlEvent/listCustomRate', [
        ]);

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