@@ -44,7 +44,7 @@ public function testAttribute()
44
44
$ listener = new IsGrantedAttributeListener ($ authChecker );
45
45
$ listener ->onKernelControllerArguments ($ event );
46
46
47
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
47
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
48
48
$ authChecker ->expects ($ this ->once ())
49
49
->method ('isGranted ' )
50
50
->willReturn (true );
@@ -63,7 +63,7 @@ public function testAttribute()
63
63
64
64
public function testNothingHappensWithNoConfig ()
65
65
{
66
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
66
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
67
67
$ authChecker ->expects ($ this ->never ())
68
68
->method ('isGranted ' );
69
69
@@ -81,7 +81,7 @@ public function testNothingHappensWithNoConfig()
81
81
82
82
public function testIsGrantedCalledCorrectly ()
83
83
{
84
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
84
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
85
85
$ authChecker ->expects ($ this ->once ())
86
86
->method ('isGranted ' )
87
87
->with ('ROLE_ADMIN ' )
@@ -101,7 +101,7 @@ public function testIsGrantedCalledCorrectly()
101
101
102
102
public function testIsGrantedSubjectFromArguments ()
103
103
{
104
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
104
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
105
105
$ authChecker ->expects ($ this ->once ())
106
106
->method ('isGranted ' )
107
107
// the subject => arg2name will eventually resolve to the 2nd argument, which has this value
@@ -148,7 +148,7 @@ public function testIsGrantedSubjectFromArgumentsWithArray()
148
148
149
149
public function testIsGrantedNullSubjectFromArguments ()
150
150
{
151
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
151
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
152
152
$ authChecker ->expects ($ this ->once ())
153
153
->method ('isGranted ' )
154
154
->with ('ROLE_ADMIN ' , null )
@@ -168,7 +168,7 @@ public function testIsGrantedNullSubjectFromArguments()
168
168
169
169
public function testIsGrantedArrayWithNullValueSubjectFromArguments ()
170
170
{
171
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
171
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
172
172
$ authChecker ->expects ($ this ->once ())
173
173
->method ('isGranted ' )
174
174
->with ('ROLE_ADMIN ' , [
@@ -193,7 +193,7 @@ public function testExceptionWhenMissingSubjectAttribute()
193
193
{
194
194
$ this ->expectException (\RuntimeException::class);
195
195
196
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
196
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
197
197
198
198
$ event = new ControllerArgumentsEvent (
199
199
$ this ->createMock (HttpKernelInterface::class),
@@ -212,12 +212,12 @@ public function testExceptionWhenMissingSubjectAttribute()
212
212
*/
213
213
public function testAccessDeniedMessages (array $ attributes , ?string $ subject , string $ method , string $ expectedMessage )
214
214
{
215
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
215
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
216
216
$ authChecker ->expects ($ this ->any ())
217
217
->method ('isGranted ' )
218
218
->willReturn (false );
219
219
220
- $ expressionLanguage = $ this ->getMockBuilder (ExpressionLanguage::class)-> getMock ( );
220
+ $ expressionLanguage = $ this ->createMock (ExpressionLanguage::class);
221
221
$ expressionLanguage ->expects ($ this ->any ())
222
222
->method ('evaluate ' )
223
223
->willReturn ('bar ' );
@@ -285,7 +285,7 @@ public function testNotFoundHttpException()
285
285
286
286
public function testIsGrantedwithExpressionInAttribute ()
287
287
{
288
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
288
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
289
289
$ authChecker ->expects ($ this ->once ())
290
290
->method ('isGranted ' )
291
291
->with (new Expression ('"ROLE_ADMIN" in role_names or is_granted("POST_VIEW", subject) ' ), 'post ' )
@@ -305,13 +305,13 @@ public function testIsGrantedwithExpressionInAttribute()
305
305
306
306
public function testIsGrantedwithExpressionInSubject ()
307
307
{
308
- $ authChecker = $ this ->getMockBuilder (AuthorizationCheckerInterface::class)-> getMock ( );
308
+ $ authChecker = $ this ->createMock (AuthorizationCheckerInterface::class);
309
309
$ authChecker ->expects ($ this ->once ())
310
310
->method ('isGranted ' )
311
311
->with (new Expression ('user === subject ' ), 'author ' )
312
312
->willReturn (true );
313
313
314
- $ expressionLanguage = $ this ->getMockBuilder (ExpressionLanguage::class)-> getMock ( );
314
+ $ expressionLanguage = $ this ->createMock (ExpressionLanguage::class);
315
315
$ expressionLanguage ->expects ($ this ->once ())
316
316
->method ('evaluate ' )
317
317
->with (new Expression ('args["post"].getAuthor() ' ), [
0 commit comments