diff --git a/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php b/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php index 61b4eac95c7c..4a4e285add55 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php +++ b/src/Illuminate/Foundation/Testing/Concerns/MakesHttpRequests.php @@ -81,27 +81,25 @@ public function withHeader(string $name, string $value) } /** - * Flush all the configured headers. + * Add an authorization token for the request. * + * @param string $token + * @param string $type * @return $this */ - public function flushHeaders() + public function withToken(string $token, string $type = 'Bearer') { - $this->defaultHeaders = []; - - return $this; + return $this->withHeader('Authorization', $type.' '.$token); } /** - * Add an authorization token for the request. + * Flush all the configured headers. * - * @param string $token - * @param string|null $type * @return $this */ - public function withToken(string $token, string $type = null) + public function flushHeaders() { - $this->defaultHeaders['Authorization'] = sprintf('%s %s', $type ?? 'Bearer', $token); + $this->defaultHeaders = []; return $this; }