質問編集履歴
1
自己解決
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Mock
|
1
|
+
MockでS3Exceptionを発生させたい
|
test
CHANGED
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
S3ClientメソッドheadObjectを使用している
|
5
|
+
自作関数hogeをテストしようとしています。hoge()内で、S3ClientメソッドheadObjectを使用しているため、headObject()をMock化しています。
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
+
そのテストケースとして、hoge関数内で、
|
10
|
+
|
9
|
-
|
11
|
+
「Aws\S3\Exception\S3Exception発生時のテスト」をしたいので、Mockで設定したいのですが、うまくいかずUT実行時にエラーになってしまいます。
|
10
12
|
|
11
13
|
|
12
14
|
|
@@ -24,7 +26,7 @@
|
|
24
26
|
|
25
27
|
->with(m::any())
|
26
28
|
|
27
|
-
->andThrow(new S3Exception(
|
29
|
+
->andThrow(new S3Exception('', new Command('')));
|
28
30
|
|
29
31
|
|
30
32
|
|
@@ -48,10 +50,10 @@
|
|
48
50
|
|
49
51
|
|
50
52
|
|
51
|
-
```
|
52
53
|
|
53
|
-
[UT実行時エラー]
|
54
54
|
|
55
|
-
|
55
|
+
~~[UT実行時エラー]
|
56
56
|
|
57
|
+
Fuel\Core\PhpErrorException: Argument 2 passed to Aws\Exception\AwsException::__construct() must implement interface Aws\CommandInterface, none given, called in ...~~
|
58
|
+
|
57
|
-
|
59
|
+
→ parametereを追加したら、エラーは消えましたが期待値と異なったので、hoge()内を確認し、エラー制御に問題があったことが分かりました。
|