49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use app\model\User;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use Tests\HttpBase;
|
|
|
|
use Tests\Utils\ClassMethodScanner;
|
|
|
|
class TestJwt extends TestCase
|
|
{
|
|
/**
|
|
* Summary of testJwt
|
|
* @param mixed $url
|
|
* @param mixed $expected
|
|
* @return void
|
|
* @dataProvider additiontJwt
|
|
*/
|
|
public function testJwt($url, $expected)
|
|
{
|
|
$data = [
|
|
"username" => '',
|
|
"password" => '',
|
|
];
|
|
$res = HttpBase::httpclient($data, $url, 'POST', null, 'form');
|
|
$this->assertEquals($expected, $res);
|
|
}
|
|
public function additiontJwt()
|
|
{
|
|
$scanner = new ClassMethodScanner();
|
|
|
|
// 指定目录路径
|
|
$directory = 'app/controller/api/';
|
|
|
|
// 获取类和方法
|
|
$classesAndMethods = $scanner->getClassesAndMethods($directory);
|
|
|
|
$url_array = [];
|
|
// 输出所有类和方法
|
|
foreach ($classesAndMethods as $url) {
|
|
// 拼接描述并将状态码 401 加入
|
|
$url_array['测试不登录接口访问 ' . $url] = [$url, 401];
|
|
}
|
|
return $url_array;
|
|
}
|
|
}
|