From bc6a419ba535198f045bd15db5361339bd8b9274 Mon Sep 17 00:00:00 2001 From: gaobinzhan Date: Tue, 11 Aug 2020 15:23:11 +0800 Subject: [PATCH] set path null --- src/Handler/AbstractClient.php | 2 +- src/HttpClient.php | 2 +- tests/HttpTest.php | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Handler/AbstractClient.php b/src/Handler/AbstractClient.php index 8a91271..341d1a2 100644 --- a/src/Handler/AbstractClient.php +++ b/src/Handler/AbstractClient.php @@ -54,7 +54,7 @@ public function setQuery(?array $data) } } - public function setPath(string $path) + public function setPath(?string $path = null) { // 请求时当前对象没有设置Url if (!($this->url instanceof Url)) { diff --git a/src/HttpClient.php b/src/HttpClient.php index dbb1daf..9c7c434 100644 --- a/src/HttpClient.php +++ b/src/HttpClient.php @@ -61,7 +61,7 @@ public function setUrl($url): HttpClient return $this; } - public function setPath(string $path): HttpClient + public function setPath(?string $path = null): HttpClient { $this->clientHandler->setPath($path); return $this; diff --git a/tests/HttpTest.php b/tests/HttpTest.php index f567dd1..795f2c5 100644 --- a/tests/HttpTest.php +++ b/tests/HttpTest.php @@ -443,6 +443,11 @@ public function testSetPath() $res = $httpClient->get(); $res = $res->getBody(); $this->assertContains('admin@fosuss.com', $res); + $httpClient->setPath(); + $res = $httpClient->get(); + $res = $res->getBody(); + $this->assertContains('一种愉悦的开发方式', $res); + } public function testSetMethod()