10
10
use PHPUnit \Framework \TestCase ;
11
11
use Symfony \Component \DependencyInjection \ContainerBuilder ;
12
12
use Symfony \Component \DependencyInjection \ContainerInterface ;
13
+ use Symfony \Component \DependencyInjection \Definition ;
13
14
use Symfony \Component \DependencyInjection \Reference ;
14
15
15
16
class AwsExtensionTest extends TestCase
@@ -24,7 +25,7 @@ class AwsExtensionTest extends TestCase
24
25
*/
25
26
protected $ container ;
26
27
27
- public function setUp ()
28
+ public function setUp (): void
28
29
{
29
30
$ this ->kernel = new AppKernel ('test ' , true );
30
31
$ this ->kernel ->boot ();
@@ -38,9 +39,9 @@ public function setUp()
38
39
public function sdk_config_should_be_passed_directly_to_the_constructor_and_resolved_by_the_sdk ()
39
40
{
40
41
$ config = $ this ->kernel ->getTestConfig ()['aws ' ];
41
- $ s3Region = isset ( $ config ['S3 ' ]['region ' ]) ? $ config [ ' S3 ' ][ ' region ' ] : $ config ['region ' ];
42
- $ lambdaRegion = isset ( $ config ['Lambda ' ]['region ' ]) ? $ config [ ' Lambda ' ][ ' region ' ] : $ config ['region ' ];
43
- $ codeDeployRegion = isset ( $ config ['CodeDeploy ' ]['region ' ]) ? $ config [ ' CodeDeploy ' ][ ' region ' ] : $ config ['region ' ];
42
+ $ s3Region = $ config ['S3 ' ]['region ' ] ?? $ config ['region ' ];
43
+ $ lambdaRegion = $ config ['Lambda ' ]['region ' ] ?? $ config ['region ' ];
44
+ $ codeDeployRegion = $ config ['CodeDeploy ' ]['region ' ] ?? $ config ['region ' ];
44
45
45
46
$ testService = $ this ->container ->get ('test_service ' );
46
47
@@ -76,13 +77,16 @@ public function extension_should_escape_strings_that_begin_with_at_sign()
76
77
'secret ' => '@@secret '
77
78
]];
78
79
$ container = $ this ->getMockBuilder (ContainerBuilder::class)
79
- ->setMethods (['getDefinition ' , 'replaceArgument ' ])
80
+ ->onlyMethods (['getDefinition ' ])
81
+ ->getMock ();
82
+ $ definition = $ this ->getMockBuilder (Definition::class)
83
+ ->onlyMethods (['replaceArgument ' ])
80
84
->getMock ();
81
85
$ container ->expects ($ this ->once ())
82
86
->method ('getDefinition ' )
83
87
->with ('aws_sdk ' )
84
- ->willReturnSelf ( );
85
- $ container ->expects ($ this ->once ())
88
+ ->willReturn ( $ definition );
89
+ $ definition ->expects ($ this ->once ())
86
90
->method ('replaceArgument ' )
87
91
->with (0 , $ this ->callback (function ($ arg ) {
88
92
return is_array ($ arg )
@@ -104,13 +108,16 @@ public function extension_should_expand_service_references()
104
108
$ extension = new AwsExtension ;
105
109
$ config = ['credentials ' => '@aws_sdk ' ];
106
110
$ container = $ this ->getMockBuilder (ContainerBuilder::class)
107
- ->setMethods (['getDefinition ' , 'replaceArgument ' ])
111
+ ->onlyMethods (['getDefinition ' ])
112
+ ->getMock ();
113
+ $ definition = $ this ->getMockBuilder (Definition::class)
114
+ ->onlyMethods (['replaceArgument ' ])
108
115
->getMock ();
109
116
$ container ->expects ($ this ->once ())
110
117
->method ('getDefinition ' )
111
118
->with ('aws_sdk ' )
112
- ->willReturnSelf ( );
113
- $ container ->expects ($ this ->once ())
119
+ ->willReturn ( $ definition );
120
+ $ definition ->expects ($ this ->once ())
114
121
->method ('replaceArgument ' )
115
122
->with (0 , $ this ->callback (function ($ arg ) {
116
123
return is_array ($ arg )
@@ -137,7 +144,6 @@ public function extension_should_validate_and_merge_configs()
137
144
'stats ' => [
138
145
'http ' => true
139
146
],
140
- 'retries ' => 5 ,
141
147
'endpoint ' => 'http://localhost:8000 ' ,
142
148
'endpoint_discovery ' => [
143
149
'enabled ' => true ,
@@ -181,13 +187,16 @@ public function extension_should_validate_and_merge_configs()
181
187
'validate ' => true ,
182
188
];
183
189
$ container = $ this ->getMockBuilder (ContainerBuilder::class)
184
- ->setMethods (['getDefinition ' , 'replaceArgument ' ])
190
+ ->onlyMethods (['getDefinition ' ])
191
+ ->getMock ();
192
+ $ definition = $ this ->getMockBuilder (Definition::class)
193
+ ->onlyMethods (['replaceArgument ' ])
185
194
->getMock ();
186
195
$ container ->expects ($ this ->once ())
187
196
->method ('getDefinition ' )
188
197
->with ('aws_sdk ' )
189
- ->willReturnSelf ( );
190
- $ container ->expects ($ this ->once ())
198
+ ->willReturn ( $ definition );
199
+ $ definition ->expects ($ this ->once ())
191
200
->method ('replaceArgument ' )
192
201
->with (0 , $ this ->callback (function ($ arg ) {
193
202
return is_array ($ arg )
@@ -230,9 +239,8 @@ public function extension_should_error_merging_unknown_config_options()
230
239
'foo ' => 'baz '
231
240
];
232
241
$ container = $ this ->getMockBuilder (ContainerBuilder::class)
233
- ->setMethods (['getDefinition ' , ' replaceArgument ' ])
242
+ ->onlyMethods (['getDefinition ' ])
234
243
->getMock ();
235
-
236
244
try {
237
245
$ extension ->load ([$ config , $ configDev ], $ container );
238
246
$ this ->fail ('Should have thrown an Error or RuntimeException ' );
0 commit comments