Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mocking exceptions #49

Merged
merged 2 commits into from
Apr 13, 2022
Merged

Mocking exceptions #49

merged 2 commits into from
Apr 13, 2022

Conversation

Sammyjo20
Copy link
Collaborator

Introduces the ability to mock exceptions, including Guzzle exceptions, like ConnectException.

For example:

$mockClient = new MockClient([
    MockResponse::make(['name' => 'Sam'])->throw(new Exception('Custom Exception!')),
]);

// Or using Guzzle

$mockClient = new MockClient([
    MockResponse::make(['name' => 'Sam'])->throw(fn ($guzzleRequest) => new GuzzleException('Cannot connect!', $guzzleRequest)),
]);

@Sammyjo20 Sammyjo20 marked this pull request as ready for review April 13, 2022 18:32
Copy link
Collaborator Author

@Sammyjo20 Sammyjo20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self review complete

@Sammyjo20 Sammyjo20 merged commit a364117 into main Apr 13, 2022
@Sammyjo20 Sammyjo20 deleted the feature/mock-exceptions branch April 13, 2022 18:39
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.

None yet

1 participant