WeChatDeveloper/tests/JsonClientTest.php
Anyon 27c6d03cbd test: 迁移测试目录并补充协议层用例
- 将 src/Tests 迁移到根目录 tests,并同步 composer autoload-dev 与 phpunit 配置。

- 补充 raw/download/upload、微信支付签名下载、XML 嵌套重复节点和消息加解密异常用例。

- 保持测试命名空间 We\Tests,统一通过 tests/bootstrap.php 引导 Composer 自动加载。
2026-05-08 00:29:23 +08:00

48 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
/**
* JSON HTTP 客户端安全约束测试。
*/
namespace We\Tests;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use We\Exception\ApiException;
use We\Support\JsonClient;
/**
* JSON HTTP 客户端安全约束测试用例。
*/
#[CoversClass(JsonClient::class)]
final class JsonClientTest extends TestCase
{
/**
* 测试 JSON 客户端拒绝绝对 URL。
*/
public function testSendRejectsAbsoluteUri(): void
{
$client = new JsonClient();
$this->expectException(ApiException::class);
$this->expectExceptionMessage('相对路径');
$client->send('GET', 'https://example.com/evil');
}
/**
* 测试 JSON 客户端拒绝网络路径 URL。
*/
public function testSendRejectsNetworkPathUri(): void
{
$client = new JsonClient();
$this->expectException(ApiException::class);
$this->expectExceptionMessage('相对路径');
$client->send('GET', '//example.com/evil');
}
}