我需要模拟以下代码的帮助:
try {
$s3Client = new S3Client([
'region' => getenv('AWS_REGION'),
'version' => 'latest',
]);
$result = $s3Client->getObject([
'Bucket' => getenv('AWS_BUCKET_NAME'),
'Key' => 'KEY'
]);
} catch (S3Exception $e) {
$cacheRequired = true;
}
我想编写测试以模拟上面的服务。
我已经尝试过了:
$awsS3Service = Mockery::mock(S3Client::class)->makePartial();
$awsS3Service
->shouldReceive('getObject')
->andReturn(NULL);