token) { return $this->token; } $response = static::createClient()->request('POST', '/auth/login', ['json' => $body ?: [ 'username' => 'ogadmin', 'password' => '12345678', ]]); $this->assertResponseIsSuccessful(); $data = $response->toArray(); $this->token = $data['token']; return $data['token']; } /** * @throws TransportExceptionInterface * @throws ServerExceptionInterface * @throws RedirectionExceptionInterface * @throws DecodingExceptionInterface * @throws ClientExceptionInterface */ protected function createClientWithCredentials($token = null): Client { $token = $token ?: $this->getToken(); return static::createClient([], ['headers' => ['authorization' => 'Bearer '.$token]]); } }