Skip to content

[4.x] assertSent with typehinting - #558

Open
gdebrauwer wants to merge 2 commits into
saloonphp:v4from
gdebrauwer:assertsent-parse-typehint-request-param
Open

[4.x] assertSent with typehinting#558
gdebrauwer wants to merge 2 commits into
saloonphp:v4from
gdebrauwer:assertsent-parse-typehint-request-param

Conversation

@gdebrauwer

Copy link
Copy Markdown
Contributor

Currently, when you are faking multiple requests in a single test, you have to manually check which request you are receiving in the closure before making the real assertions on the request:

Saloon::assertSent($request, $response) {
	return $request instance of FirstRequest && $request->userId === 1;
});

Saloon::assertSent($request, $response) {
	return $request instance of SecondRequest && $request->firstname === 'Taylor';
});

This PR simplifies that by allowing you to typehint the $request parameter:

Saloon::assertSent(FirstRequest $request, $response) {
	return $request->userId === 1;
});

Saloon::assertSent(SecondRequest $request, $response) {
	return $request->firstname === 'Taylor';
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant