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

Can't mock magic methods for \Aws\S3\S3Client #45

Open
uaoleg opened this issue Sep 29, 2023 · 1 comment
Open

Can't mock magic methods for \Aws\S3\S3Client #45

uaoleg opened this issue Sep 29, 2023 · 1 comment

Comments

@uaoleg
Copy link

uaoleg commented Sep 29, 2023

\Aws\S3\S3Client has way too many magic, e.g. for method putObject()
So when I try to mock this method it's treated as a property. Possible solution is to explicitly specify if it's a method or a property:

\Codeception\Stub::makeEmpty(
    \Aws\S3\S3Client::class,
    [
        'putObject()' => 'result',
    ],
);
@SamMousa
Copy link

A better solution might not be to mock it at all.
What I do as a clean approach is this:

  1. Define an interface for the functionality that you use.
  2. Create an implementation that uses S3 client, test it using integration tests
  3. In your application tests mock your own interface.

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

No branches or pull requests

2 participants