Summer Sale! All accounts are 50% off this week.

Jafo232's avatar

http::fake() Just doesn't appear to be working..

Consider the following:

    public function prepRequest(): PendingRequest
    {
        Http::fake(['*' => Http::response(['foo' => 'bar'],  200, [])]);

        return Http::withHeaders([
                                     'Api-Key' => $this->apiKey,
                                     'Content-Type' => 'application/json',
                                 ])->baseUrl($this->endpoint);
    }

Later on in the class I call:

$response = $this->prepRequest()->patch('/api/catalogs/' . $catalogName . '/items/' . $itemId, [
                'catalogName' => $catalogName,
                'itemId' => $itemId,
                'update' =>  json_decode($data)
            ]);

And it is making the actual request to the endpoint and not faking it. What am I doing wrong?

0 likes
2 replies

Please or to participate in this conversation.