1414namespace FOS \OAuthServerBundle \Tests \Controller ;
1515
1616use FOS \OAuthServerBundle \Controller \AuthorizeController ;
17- use FOS \OAuthServerBundle \Event \OAuthEvent ;
17+ use FOS \OAuthServerBundle \Event \PostAuthorizationEvent ;
18+ use FOS \OAuthServerBundle \Event \PreAuthorizationEvent ;
1819use FOS \OAuthServerBundle \Form \Handler \AuthorizeFormHandler ;
1920use FOS \OAuthServerBundle \Model \ClientInterface ;
2021use FOS \OAuthServerBundle \Model \ClientManagerInterface ;
@@ -117,9 +118,14 @@ class AuthorizeControllerTest extends \PHPUnit\Framework\TestCase
117118 protected $ client ;
118119
119120 /**
120- * @var \PHPUnit_Framework_MockObject_MockObject|OAuthEvent
121+ * @var \PHPUnit_Framework_MockObject_MockObject|PreAuthorizationEvent
121122 */
122- protected $ event ;
123+ protected $ preAuthorizationEvent ;
124+
125+ /**
126+ * @var \PHPUnit_Framework_MockObject_MockObject|PostAuthorizationEvent
127+ */
128+ protected $ postAuthorizationEvent ;
123129
124130 /**
125131 * @var \PHPUnit_Framework_MockObject_MockObject|FormView
@@ -206,7 +212,11 @@ public function setUp()
206212 ->disableOriginalConstructor ()
207213 ->getMock ()
208214 ;
209- $ this ->event = $ this ->getMockBuilder (OAuthEvent::class)
215+ $ this ->preAuthorizationEvent = $ this ->getMockBuilder (PreAuthorizationEvent::class)
216+ ->disableOriginalConstructor ()
217+ ->getMock ()
218+ ;
219+ $ this ->postAuthorizationEvent = $ this ->getMockBuilder (PostAuthorizationEvent::class)
210220 ->disableOriginalConstructor ()
211221 ->getMock ()
212222 ;
@@ -274,16 +284,15 @@ public function testAuthorizeActionWillRenderTemplate()
274284 $ propertyReflection ->setValue ($ this ->instance , $ this ->client );
275285
276286 $ this ->eventDispatcher
277- ->expects ($ this ->at ( 0 ))
287+ ->expects ($ this ->once ( ))
278288 ->method ('dispatch ' )
279- ->with (OAuthEvent:: PRE_AUTHORIZATION_PROCESS , new OAuthEvent ($ this ->user , $ this ->client ))
280- ->willReturn ($ this ->event )
289+ ->with (new PreAuthorizationEvent ($ this ->user , $ this ->client ))
290+ ->willReturn ($ this ->preAuthorizationEvent )
281291 ;
282292
283- $ this ->event
284- ->expects ($ this ->at ( 0 ))
293+ $ this ->preAuthorizationEvent
294+ ->expects ($ this ->once ( ))
285295 ->method ('isAuthorizedClient ' )
286- ->with ()
287296 ->willReturn (false )
288297 ;
289298
@@ -347,16 +356,15 @@ public function testAuthorizeActionWillFinishClientAuthorization()
347356 $ propertyReflection ->setValue ($ this ->instance , $ this ->client );
348357
349358 $ this ->eventDispatcher
350- ->expects ($ this ->at ( 0 ))
359+ ->expects ($ this ->once ( ))
351360 ->method ('dispatch ' )
352- ->with (OAuthEvent:: PRE_AUTHORIZATION_PROCESS , new OAuthEvent ($ this ->user , $ this ->client ))
353- ->willReturn ($ this ->event )
361+ ->with (new PreAuthorizationEvent ($ this ->user , $ this ->client ))
362+ ->willReturn ($ this ->preAuthorizationEvent )
354363 ;
355364
356- $ this ->event
357- ->expects ($ this ->at ( 0 ))
365+ $ this ->preAuthorizationEvent
366+ ->expects ($ this ->once ( ))
358367 ->method ('isAuthorizedClient ' )
359- ->with ()
360368 ->willReturn (true )
361369 ;
362370
@@ -431,16 +439,15 @@ public function testAuthorizeActionWillEnsureLogout()
431439 $ propertyReflection ->setValue ($ this ->instance , $ this ->client );
432440
433441 $ this ->eventDispatcher
434- ->expects ($ this ->at ( 0 ))
442+ ->expects ($ this ->once ( ))
435443 ->method ('dispatch ' )
436- ->with (OAuthEvent:: PRE_AUTHORIZATION_PROCESS , new OAuthEvent ($ this ->user , $ this ->client ))
437- ->willReturn ($ this ->event )
444+ ->with (new PreAuthorizationEvent ($ this ->user , $ this ->client ))
445+ ->willReturn ($ this ->preAuthorizationEvent )
438446 ;
439447
440- $ this ->event
441- ->expects ($ this ->at ( 0 ))
448+ $ this ->preAuthorizationEvent
449+ ->expects ($ this ->once ( ))
442450 ->method ('isAuthorizedClient ' )
443- ->with ()
444451 ->willReturn (false )
445452 ;
446453
@@ -506,11 +513,11 @@ public function testAuthorizeActionWillProcessAuthorizationForm()
506513 $ this ->eventDispatcher
507514 ->expects ($ this ->at (0 ))
508515 ->method ('dispatch ' )
509- ->with (OAuthEvent:: PRE_AUTHORIZATION_PROCESS , new OAuthEvent ($ this ->user , $ this ->client ))
510- ->willReturn ($ this ->event )
516+ ->with (new PreAuthorizationEvent ($ this ->user , $ this ->client ))
517+ ->willReturn ($ this ->preAuthorizationEvent )
511518 ;
512519
513- $ this ->event
520+ $ this ->preAuthorizationEvent
514521 ->expects ($ this ->once ())
515522 ->method ('isAuthorizedClient ' )
516523 ->willReturn (false )
@@ -531,10 +538,7 @@ public function testAuthorizeActionWillProcessAuthorizationForm()
531538 $ this ->eventDispatcher
532539 ->expects ($ this ->at (1 ))
533540 ->method ('dispatch ' )
534- ->with (
535- OAuthEvent::POST_AUTHORIZATION_PROCESS ,
536- new OAuthEvent ($ this ->user , $ this ->client , true )
537- )
541+ ->with (new PostAuthorizationEvent ($ this ->user , $ this ->client , true ))
538542 ;
539543
540544 $ formName = 'formName ' .\random_bytes (10 );
0 commit comments