@@ -129,11 +129,11 @@ public function testIsErrorOrTests() {
129
129
}
130
130
131
131
/**
132
- * testLogin method
132
+ * testIdentify method
133
133
*
134
134
* @return void
135
135
*/
136
- public function testLogin () {
136
+ public function testIdentify () {
137
137
$ AuthLoginFormAuthenticate = $ this ->getMock (
138
138
'Cake\Controller\Component\Auth\FormAuthenticate ' ,
139
139
array ('authenticate ' ), array (), '' , false
@@ -143,10 +143,6 @@ public function testLogin() {
143
143
'userModel ' => 'AuthUsers '
144
144
)
145
145
);
146
- $ this ->Auth ->session = $ this ->getMock (
147
- 'Cake\Network\Session ' ,
148
- array ('renew ' )
149
- );
150
146
151
147
$ this ->Auth ->setAuthenticateObject (0 , $ AuthLoginFormAuthenticate );
152
148
@@ -167,14 +163,8 @@ public function testLogin() {
167
163
->with ($ this ->Auth ->request )
168
164
->will ($ this ->returnValue ($ user ));
169
165
170
- $ this ->Auth ->session ->expects ($ this ->once ())
171
- ->method ('renew ' );
172
-
173
- $ result = $ this ->Auth ->login ();
174
- $ this ->assertTrue ($ result );
175
-
176
- $ this ->assertTrue ((bool )$ this ->Auth ->user ());
177
- $ this ->assertEquals ($ user , $ this ->Auth ->user ());
166
+ $ result = $ this ->Auth ->identify ();
167
+ $ this ->assertEquals ($ user , $ result );
178
168
$ this ->assertSame ($ AuthLoginFormAuthenticate , $ this ->Auth ->authenticationProvider ());
179
169
}
180
170
@@ -228,6 +218,8 @@ public function testAuthorizeFalse() {
228
218
}
229
219
230
220
/**
221
+ * testIsAuthorizedMissingFile function
222
+ *
231
223
* @expectedException \Cake\Error\Exception
232
224
* @return void
233
225
*/
@@ -317,6 +309,8 @@ public function testLoadAuthorizeResets() {
317
309
}
318
310
319
311
/**
312
+ * testLoadAuthenticateNoFile function
313
+ *
320
314
* @expectedException \Cake\Error\Exception
321
315
* @return void
322
316
*/
@@ -516,6 +510,11 @@ public function testAllowedActionsWithCamelCaseMethods() {
516
510
$ this ->assertNull ($ result , 'startup() should return null, as action is allowed. %s ' );
517
511
}
518
512
513
+ /**
514
+ * testAllowedActionsSetWithAllowMethod method
515
+ *
516
+ * @return void
517
+ */
519
518
public function testAllowedActionsSetWithAllowMethod () {
520
519
$ url = '/auth_test/action_name ' ;
521
520
$ this ->Controller ->request ->addParams (Router::parse ($ url ));
@@ -822,6 +821,7 @@ public function testRedirectToUnauthorizedRedirectSuppressedAuthError() {
822
821
823
822
/**
824
823
* Throw ForbiddenException if config `unauthorizedRedirect` is set to false
824
+ *
825
825
* @expectedException \Cake\Error\ForbiddenException
826
826
* @return void
827
827
*/
@@ -1093,36 +1093,34 @@ public function testMapActionsDelegation() {
1093
1093
}
1094
1094
1095
1095
/**
1096
- * test logging in with a request .
1096
+ * test logging in.
1097
1097
*
1098
1098
* @return void
1099
1099
*/
1100
- public function testLoginWithRequestData () {
1101
- $ RequestLoginMockAuthenticate = $ this ->getMock (
1102
- 'Cake\Controller\Component\Auth\FormAuthenticate ' ,
1103
- array ('authenticate ' ), array (), '' , false
1100
+ public function testLogin () {
1101
+ $ this -> Auth -> session = $ this ->getMock (
1102
+ 'Cake\Network\Session ' ,
1103
+ array ('renew ' , ' write ' )
1104
1104
);
1105
- $ request = new Request ( ' users/login ' );
1105
+
1106
1106
$ user = array ('username ' => 'mark ' , 'role ' => 'admin ' );
1107
1107
1108
- $ this ->Auth ->request = $ request ;
1109
- $ this ->Auth ->authenticate = array ('RequestLoginMock ' );
1110
- $ this ->Auth ->setAuthenticateObject (0 , $ RequestLoginMockAuthenticate );
1111
- $ RequestLoginMockAuthenticate ->expects ($ this ->once ())
1112
- ->method ('authenticate ' )
1113
- ->with ($ request )
1114
- ->will ($ this ->returnValue ($ user ));
1108
+ $ this ->Auth ->session ->expects ($ this ->once ())
1109
+ ->method ('renew ' );
1115
1110
1116
- $ this ->assertTrue ($ this ->Auth ->login ());
1117
- $ this ->assertEquals ($ user ['username ' ], $ this ->Auth ->user ('username ' ));
1111
+ $ this ->Auth ->session ->expects ($ this ->once ())
1112
+ ->method ('write ' )
1113
+ ->with ($ this ->Auth ->sessionKey , $ user );
1114
+
1115
+ $ this ->Auth ->login ($ user );
1118
1116
}
1119
1117
1120
1118
/**
1121
- * test login() with user data
1119
+ * testGettingUserAfterLogin
1122
1120
*
1123
1121
* @return void
1124
1122
*/
1125
- public function testLoginWithUserData () {
1123
+ public function testGettingUserAfterLogin () {
1126
1124
$ this ->assertFalse ((bool )$ this ->Auth ->user ());
1127
1125
1128
1126
$ user = array (
@@ -1131,7 +1129,7 @@ public function testLoginWithUserData() {
1131
1129
'created ' => new \DateTime ('2007-03-17 01:16:23 ' ),
1132
1130
'updated ' => new \DateTime ('2007-03-17 01:18:31 ' )
1133
1131
);
1134
- $ this ->assertTrue ( $ this -> Auth ->login ($ user) );
1132
+ $ this ->Auth ->login ($ user );
1135
1133
$ this ->assertTrue ((bool )$ this ->Auth ->user ());
1136
1134
$ this ->assertEquals ($ user ['username ' ], $ this ->Auth ->user ('username ' ));
1137
1135
}
0 commit comments