@@ -36,7 +36,7 @@ class BasicAuthenticateTest extends CakeTestCase {
36
36
*
37
37
* @var array
38
38
*/
39
- public $ fixtures = array ('core.user ' , 'core.auth_user ' );
39
+ public $ fixtures = array ('core.user ' , 'core.auth_user ' , ' core.article ' );
40
40
41
41
/**
42
42
* setup
@@ -197,6 +197,35 @@ public function testAuthenticateSuccess() {
197
197
$ this ->assertEquals ($ expected , $ result );
198
198
}
199
199
200
+ /**
201
+ * test contain success
202
+ *
203
+ * @return void
204
+ */
205
+ public function testAuthenticateContainSuccess () {
206
+ $ User = ClassRegistry::init ('User ' );
207
+ $ User ->bindModel (array ('hasMany ' => array ('Article ' )));
208
+ $ User ->Behaviors ->load ('Containable ' );
209
+ $ this ->auth ->settings ['contain ' ] = 'Article ' ;
210
+ $ request = new CakeRequest ('posts/index ' , false );
211
+ $ request ->addParams (array ('pass ' => array (), 'named ' => array ()));
212
+
213
+ $ _SERVER ['PHP_AUTH_USER ' ] = 'mariano ' ;
214
+ $ _SERVER ['PHP_AUTH_PW ' ] = 'password ' ;
215
+
216
+ $ result = $ this ->auth ->authenticate ($ request , $ this ->response );
217
+ $ expected = array (
218
+ 'id ' => 1 ,
219
+ 'user_id ' => 1 ,
220
+ 'title ' => 'First Article ' ,
221
+ 'body ' => 'First Article Body ' ,
222
+ 'published ' => 'Y ' ,
223
+ 'created ' => '2007-03-18 10:39:23 ' ,
224
+ 'updated ' => '2007-03-18 10:41:31 '
225
+ );
226
+ $ this ->assertEquals ($ expected , $ result ['Article ' ][0 ]);
227
+ }
228
+
200
229
/**
201
230
* test userFields success
202
231
*
0 commit comments