Open alex-billetsca opened 1 year ago
what is the use case for mocking this method though ? You can use the actual one.
Simple use case - write a test for this class: I don't care about the internals of the s3 client (just like I wouldn't for any other service).
class AsyncAwsAdapter {
public function __construct(
private readonly S3Client $s3Client,
private readonly string $bucket,
private readonly string $path = ''
) {
}
public function doSomeCall(string $name): string {
return $this->s3Client->presign(
new GetObjectRequest([
'Bucket' => $this->bucket,
'Key' => $this->path,
]),
new DateTimeImmutable('2 hours'),
);
}
}
This makes testing impossible as you cannot mock the presign!
--
I am aware of libs that override the loading mechanisms - this does not always work depending on how CI/CD builds are configured. It should not be a requirement to be able to properly test against this lib.