<?php

namespace Tests\Channel\Http\Controllers;

use Modules\Channel\Http\Controllers\AdvertiserController;
use PHPUnit\Framework\TestCase;
use Tests\UsedTestCase;

class AdvertiserControllerTest extends UsedTestCase
{

    public function testAddAdvertiser()
    {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('post','http://localhost/api/channel/advertiser/add', [
            'email' => 'aa4@test.com',
            'password' => '123',
            'repassword' => '123',
            'status' => 1,
            'remark' => 'kljlkjkj',
            'miniProgramIds'=> [1,2,3],
            'username' => 'aa1@test'
        ]);
        $res->dump();
    }

    public function testlistAdvertiser() {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('get','http://localhost/api/channel/advertiser/listAdvertiser?'.http_build_query([
//                'email' => 'aa1@test.com',
//                'miniProgramId' => 3,
            ]));
        $this->dumpJson($res);
    }

    public function testgetAdvertiser() {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('get','http://localhost/api/channel/advertiser/getAdvertiser?'.http_build_query([
//                'email' => 'aa1@test.com',
//                'miniProgramId' => 3,
                'id' => 6
            ]));
        $this->dumpJson($res);
    }

    public function testupdateAdvertiser() {
        $res = $this->withHeaders([
            'Authorization' => 'Bearer '. $this->token,
        ])->json('post','http://localhost/api/channel/advertiser/updateAdvertiser', [
            'id' => 6,
            'username' => 'change@aa@test',
            'miniProgramIds' => [1,5,6,7],
            'status' => 0,
            'remark' => 'first change'
        ]);
    }
}
