phpstorm教學欄位給大家介紹phpstorm hyperf單元測試配置,希望對需要的朋友有所幫助!
client = di(Client::class); $this->login(); } public function __call($name, $arguments) { return $this->client->{$name}(...$arguments); } /** * @return mixed|string * @throws \Psr\SimpleCache\InvalidArgumentException */ public function login() { $token = cache()->get($this->cacheKey); $this->header['token'] = $token; if (!$token) { $userId = 1; $user = SysUser::query()->where(['user_id' => $userId])->first(); $token = JwtInstance::instance()->encode($user); $this->header['token'] = $token; // 设置到缓存 cache()->set($this->cacheKey, $token, 43200); } return $token; } /** * @param array $result * @return false|string */ public function pretty(array $result) { // 表示成功 $this->assertSame(0, 0); echo json_encode($result, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL; } }
assertTrue(true); $res = $this->client->get('/'); // $this->assertSame(0, $res['code']); $this->pretty($res); } /** * 后台用户列表 * 执行命令:composer test -- --filter testGetSysUserList --group adminUser * * @group adminUser */ public function testGetSysUserList() { $params = [ 'username' => '', 'page' => 1, 'limit' => 20 ]; $result = $this->get('/admin/sys/user/list', $params, $this->header); $this->pretty($result); } }
composer test -- --filter testGetSysUserList --group adminUser
#已配置完點擊【OK】或【Apply】
點選【OK】
如圖所示配置,點選【OK】或【Apply】儲存
以上是教你進行phpstorm hyperf單元測試配置的詳細內容。更多資訊請關注PHP中文網其他相關文章!