@@ -35,18 +35,18 @@ class UsernamePasswordJsonAuthenticationListenerTest extends \PHPUnit_Framework_
35
35
36
36
private function createListener (array $ options = array (), $ success = true )
37
37
{
38
- $ tokenStorage = $ this ->getMock (TokenStorageInterface::class);
39
- $ authenticationManager = $ this ->getMock (AuthenticationManagerInterface::class);
38
+ $ tokenStorage = $ this ->getMockBuilder (TokenStorageInterface::class)-> getMock ( );
39
+ $ authenticationManager = $ this ->getMockBuilder (AuthenticationManagerInterface::class)-> getMock ( );
40
40
41
41
if ($ success ) {
42
42
$ authenticationManager ->method ('authenticate ' )->willReturn (true );
43
43
} else {
44
44
$ authenticationManager ->method ('authenticate ' )->willThrowException (new AuthenticationException ());
45
45
}
46
46
47
- $ authenticationSuccessHandler = $ this ->getMock (AuthenticationSuccessHandlerInterface::class);
47
+ $ authenticationSuccessHandler = $ this ->getMockBuilder (AuthenticationSuccessHandlerInterface::class)-> getMock ( );
48
48
$ authenticationSuccessHandler ->method ('onAuthenticationSuccess ' )->willReturn (new Response ('ok ' ));
49
- $ authenticationFailureHandler = $ this ->getMock (AuthenticationFailureHandlerInterface::class);
49
+ $ authenticationFailureHandler = $ this ->getMockBuilder (AuthenticationFailureHandlerInterface::class)-> getMock ( );
50
50
$ authenticationFailureHandler ->method ('onAuthenticationFailure ' )->willReturn (new Response ('ko ' ));
51
51
52
52
$ this ->listener = new UsernamePasswordJsonAuthenticationListener ($ tokenStorage , $ authenticationManager , 'providerKey ' , $ authenticationSuccessHandler , $ authenticationFailureHandler , $ options );
@@ -56,7 +56,7 @@ public function testHandleSuccess()
56
56
{
57
57
$ this ->createListener ();
58
58
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"username": "dunglas", "password": "foo"} ' );
59
- $ event = new GetResponseEvent ($ this ->getMock (KernelInterface::class), $ request , KernelInterface::MASTER_REQUEST );
59
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)-> getMock ( ), $ request , KernelInterface::MASTER_REQUEST );
60
60
61
61
$ this ->listener ->handle ($ event );
62
62
$ this ->assertEquals ('ok ' , $ event ->getResponse ()->getContent ());
@@ -66,7 +66,7 @@ public function testHandleFailure()
66
66
{
67
67
$ this ->createListener (array (), false );
68
68
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"username": "dunglas", "password": "foo"} ' );
69
- $ event = new GetResponseEvent ($ this ->getMock (KernelInterface::class), $ request , KernelInterface::MASTER_REQUEST );
69
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)-> getMock ( ), $ request , KernelInterface::MASTER_REQUEST );
70
70
71
71
$ this ->listener ->handle ($ event );
72
72
$ this ->assertEquals ('ko ' , $ event ->getResponse ()->getContent ());
@@ -76,7 +76,7 @@ public function testUsePath()
76
76
{
77
77
$ this ->createListener (array ('username_path ' => 'user.login ' , 'password_path ' => 'user.pwd ' ));
78
78
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"user": {"login": "dunglas", "pwd": "foo"}} ' );
79
- $ event = new GetResponseEvent ($ this ->getMock (KernelInterface::class), $ request , KernelInterface::MASTER_REQUEST );
79
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)-> getMock ( ), $ request , KernelInterface::MASTER_REQUEST );
80
80
81
81
$ this ->listener ->handle ($ event );
82
82
$ this ->assertEquals ('ok ' , $ event ->getResponse ()->getContent ());
@@ -89,7 +89,7 @@ public function testAttemptAuthenticationNoUsername()
89
89
{
90
90
$ this ->createListener ();
91
91
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"usr": "dunglas", "password": "foo"} ' );
92
- $ event = new GetResponseEvent ($ this ->getMock (KernelInterface::class), $ request , KernelInterface::MASTER_REQUEST );
92
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)-> getMock ( ), $ request , KernelInterface::MASTER_REQUEST );
93
93
94
94
$ this ->listener ->handle ($ event );
95
95
}
@@ -101,7 +101,7 @@ public function testAttemptAuthenticationNoPassword()
101
101
{
102
102
$ this ->createListener ();
103
103
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"username": "dunglas", "pass": "foo"} ' );
104
- $ event = new GetResponseEvent ($ this ->getMock (KernelInterface::class), $ request , KernelInterface::MASTER_REQUEST );
104
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)-> getMock ( ), $ request , KernelInterface::MASTER_REQUEST );
105
105
106
106
$ this ->listener ->handle ($ event );
107
107
}
@@ -113,7 +113,7 @@ public function testAttemptAuthenticationUsernameNotAString()
113
113
{
114
114
$ this ->createListener ();
115
115
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"username": 1, "password": "foo"} ' );
116
- $ event = new GetResponseEvent ($ this ->getMock (KernelInterface::class), $ request , KernelInterface::MASTER_REQUEST );
116
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)-> getMock ( ), $ request , KernelInterface::MASTER_REQUEST );
117
117
118
118
$ this ->listener ->handle ($ event );
119
119
}
@@ -125,7 +125,7 @@ public function testAttemptAuthenticationPasswordNotAString()
125
125
{
126
126
$ this ->createListener ();
127
127
$ request = new Request (array (), array (), array (), array (), array (), array (), '{"username": "dunglas", "password": 1} ' );
128
- $ event = new GetResponseEvent ($ this ->getMock (KernelInterface::class), $ request , KernelInterface::MASTER_REQUEST );
128
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)-> getMock ( ), $ request , KernelInterface::MASTER_REQUEST );
129
129
130
130
$ this ->listener ->handle ($ event );
131
131
}
@@ -138,7 +138,7 @@ public function testAttemptAuthenticationUsernameTooLong()
138
138
$ this ->createListener ();
139
139
$ username = str_repeat ('x ' , Security::MAX_USERNAME_LENGTH + 1 );
140
140
$ request = new Request (array (), array (), array (), array (), array (), array (), sprintf ('{"username": "%s", "password": 1} ' , $ username ));
141
- $ event = new GetResponseEvent ($ this ->getMock (KernelInterface::class), $ request , KernelInterface::MASTER_REQUEST );
141
+ $ event = new GetResponseEvent ($ this ->getMockBuilder (KernelInterface::class)-> getMock ( ), $ request , KernelInterface::MASTER_REQUEST );
142
142
143
143
$ this ->listener ->handle ($ event );
144
144
}
0 commit comments