You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Somehow it's exhausting to bring all the fake data into a nice structure. Having them in static files is often very impractical.
I like the concept of laravel factories, so I had the idea of doing something similar for mock responses!?
<?phpuseSaloon\Http\Faking\MockClient;
useSaloon\Http\Request;
#[UseMockResponseFactory(GetServersMockResponseFactory::class)]
class GetServers extends Request
{
/** @use HasMockResponseFactory<GetServersMockResponseFactory> */use HasMockResponseFactory;
publicfunctionresolveEndpoint(): string
{
return'servers';
}
}
MockClient::global([
GetServers::class => GetServers::mockResponseFactory()->success(),
// or
GetServers::class => GetServers::mockResponseFactory()->error(),
// or
GetServers::class => GetServers::mockResponseFactory()->validationError(),
// or
GetServers::class => GetServers::mockResponseFactory()->validationError('email'),
// or
GetServers::class => GetServers::mockResponseFactory()->customName(),
...
]);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Somehow it's exhausting to bring all the fake data into a nice structure. Having them in static files is often very impractical.
I like the concept of laravel factories, so I had the idea of doing something similar for mock responses!?
Beta Was this translation helpful? Give feedback.
All reactions