ThinkAdmin/tests/support/TestSystemContext.php
Anyon e7a8c05556 chore(repo): 统一 v8 仓库品牌名称
将 v8 重构分支中残留的 ThinkAdminDeveloper 文本统一调整为 ThinkAdmin,避免迁移到主仓库后继续暴露旧开发仓库名称。

主要内容:

- 更新 README 标题与项目描述。

- 统一 PHP 文件头注释中的项目标识。

- 同步调整测试、配置、插件与文档中的旧仓库名称文本。

- 保持旧包删除说明与架构边界测试语义不变,只清理品牌名称残留。
2026-05-08 16:15:24 +08:00

142 lines
3.4 KiB
PHP

<?php
declare(strict_types=1);
/**
* +----------------------------------------------------------------------
* | ThinkAdmin Plugin
* +----------------------------------------------------------------------
* | Copyright (c) 2014~2026 ThinkAdmin [ thinkadmin.top ]
* +----------------------------------------------------------------------
* | Official Website: https://thinkadmin.top
* +----------------------------------------------------------------------
* | Licensed: https://mit-license.org
* | Disclaimer: https://thinkadmin.top/disclaimer
* | Vip Rights: https://thinkadmin.top/vip-introduce
* +----------------------------------------------------------------------
* | Gitee Repository: https://gitee.com/zoujingli/ThinkAdmin
* | Github Repository: https://github.com/zoujingli/ThinkAdmin
* +----------------------------------------------------------------------
*/
namespace think\admin\tests\Support;
use think\admin\contract\SystemContextInterface;
class TestSystemContext implements SystemContextInterface
{
private array $data = [];
private array $user = [];
private int $userId = 0;
private bool $super = false;
private bool $login = false;
private array $nodes = [];
public function buildToken(): string
{
return '';
}
public function getTokenHeader(): string
{
return 'Authorization';
}
public function getTokenCookie(): string
{
return 'system_access_token';
}
public function getTokenType(): string
{
return 'system-auth';
}
public function syncTokenCookie(?string $token = null): string
{
return strval($token);
}
public function check(?string $node = ''): bool
{
if ($this->super) {
return true;
}
return $node !== null && in_array($node, $this->nodes, true);
}
public function getUser(?string $field = null, $default = null)
{
if ($field === null) {
return $this->user;
}
return $this->user[$field] ?? $default;
}
public function getUserId(): int
{
return $this->userId;
}
public function isSuper(): bool
{
return $this->super;
}
public function isLogin(): bool
{
return $this->login;
}
public function withUploadUnid(?string $uptoken = null): array
{
return [0, []];
}
public function clearAuth(): bool
{
return true;
}
public function getData(string $name, $default = [])
{
return $this->data[$name] ?? $default;
}
public function setData(string $name, $value): bool
{
$this->data[$name] = $value;
return true;
}
public function setOplog(string $action, string $content): bool
{
return true;
}
public function baseItems(string $type, array &$data = [], string $field = 'base_code', string $bind = 'base_info'): array
{
return [];
}
public function setUser(array $user = [], bool $login = false, bool $super = false): self
{
$this->user = $user;
$this->userId = intval($user['id'] ?? 0);
$this->login = $login;
$this->super = $super;
return $this;
}
public function setNodes(array $nodes = []): self
{
$this->nodes = array_values(array_unique(array_filter(array_map('strval', $nodes))));
return $this;
}
}