Skip to content

[7.x] Add assertSentCount HTTP client assertion#32407

Merged
taylorotwell merged 1 commit into
laravel:7.xfrom
christophrumpel:feature/addRequestCountAssertion
Apr 16, 2020
Merged

[7.x] Add assertSentCount HTTP client assertion#32407
taylorotwell merged 1 commit into
laravel:7.xfrom
christophrumpel:feature/addRequestCountAssertion

Conversation

@christophrumpel
Copy link
Copy Markdown
Contributor

This PR adds a new HTTP client assertion called assertSentCount.

Next to the given assertions, it is also useful to count the recorded requests. This way you can make sure your code only sends x amount of requests and you do not have to be more specific how they look like. Here is an example:

$this->factory->fake();

$this->factory->assertSentCount(0);

$this->factory->post('http://foo.com/form', [
       'name' => 'Taylor',
]);

$this->factory->assertSentCount(1);

$this->factory->post('http://foo.com/form', [
       'name' => 'Jim',
]);

$this->factory->assertSentCount(2);

@taylorotwell taylorotwell merged commit b92e27d into laravel:7.x Apr 16, 2020
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.

2 participants