Skip to content

Commit f6c7102

Browse files
Add test for the 'contain' setting, which was missing (unrelated to feature)
1 parent 2f62ee2 commit f6c7102

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class BasicAuthenticateTest extends CakeTestCase {
3636
*
3737
* @var array
3838
*/
39-
public $fixtures = array('core.user', 'core.auth_user');
39+
public $fixtures = array('core.user', 'core.auth_user', 'core.article');
4040

4141
/**
4242
* setup
@@ -197,6 +197,35 @@ public function testAuthenticateSuccess() {
197197
$this->assertEquals($expected, $result);
198198
}
199199

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+
200229
/**
201230
* test userFields success
202231
*

0 commit comments

Comments
 (0)