Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 如何模拟供应商包? 使用嘲弄; 使用Tests\TestCase; 使用Aws\S3\S3客户端; 使用App\Services\S3Service; 类S3ServiceTest扩展了TestCase { 私人服务;; 私人客户; 受保护的函数设置():void { $this->client=mockry::mock('重载:'.S3Client::class); $this->service=new S3Service(); } /**@测试*/ 公共函数可以生成预先签名的url() { $this->client->shouldReceive('getCommand')->once(); $this->service->generatePreSinedUrl('putObject'[ 'Bucket'=>config('filesystems.disks.s3.Bucket'), '键'=>'测试键', ]); } }_Laravel_Phpunit - Fatal编程技术网

Laravel 如何模拟供应商包? 使用嘲弄; 使用Tests\TestCase; 使用Aws\S3\S3客户端; 使用App\Services\S3Service; 类S3ServiceTest扩展了TestCase { 私人服务;; 私人客户; 受保护的函数设置():void { $this->client=mockry::mock('重载:'.S3Client::class); $this->service=new S3Service(); } /**@测试*/ 公共函数可以生成预先签名的url() { $this->client->shouldReceive('getCommand')->once(); $this->service->generatePreSinedUrl('putObject'[ 'Bucket'=>config('filesystems.disks.s3.Bucket'), '键'=>'测试键', ]); } }

Laravel 如何模拟供应商包? 使用嘲弄; 使用Tests\TestCase; 使用Aws\S3\S3客户端; 使用App\Services\S3Service; 类S3ServiceTest扩展了TestCase { 私人服务;; 私人客户; 受保护的函数设置():void { $this->client=mockry::mock('重载:'.S3Client::class); $this->service=new S3Service(); } /**@测试*/ 公共函数可以生成预先签名的url() { $this->client->shouldReceive('getCommand')->once(); $this->service->generatePreSinedUrl('putObject'[ 'Bucket'=>config('filesystems.disks.s3.Bucket'), '键'=>'测试键', ]); } },laravel,phpunit,Laravel,Phpunit,我正在尝试测试我的类S3Service与S3Client的集成 使用Aws\S3\S3客户端; AWSS3类服务 { 私人客户; 公共函数构造() { $this->client=新客户端([ “版本”=>“2006-03-01”, 'region'=>config('filesystems.disks.s3.region'), “签名版本”=>“v4”, “凭证”=>[ 'key'=>config('filesystems.disks.s3.key'), 'secret'=>config('f

我正在尝试测试我的类
S3Service
S3Client的集成

使用Aws\S3\S3客户端;
AWSS3类服务
{
私人客户;
公共函数构造()
{
$this->client=新客户端([
“版本”=>“2006-03-01”,
'region'=>config('filesystems.disks.s3.region'),
“签名版本”=>“v4”,
“凭证”=>[
'key'=>config('filesystems.disks.s3.key'),
'secret'=>config('filesystems.disks.s3.secret'),
],
]);
}
公共函数GeneratePresideUrl(字符串$action,数组$options,$expireAfter='+5分钟')
{
$command=$this->client->getCommand($action,$options);
返回$this->client->createPresignedRequest($command,$expireAfter);
}
}
但我得到了这个错误:
mockry\Exception\BadMethodCallException:Method Aws\S3\S3Client::getCommand()在此模拟对象上不存在
,我假设它与我正在使用的
重载
关键字有关,但我不确定


如何将
Aws\S3\S3Client
作为一个供应商包来测试
AwsS3Service
。您可以发布测试中引用的
S3Service
类吗?我也在尝试这样做,但由于模拟未应用于S3Client类,所以出现了错误。您可以发布测试中引用的
S3Service
类吗?