Add test for userFields and related models

This commit is contained in:
Sebastien Barre 2014-10-31 16:35:55 -04:00
parent f6c71024c5
commit 60917974bf

View file

@ -247,6 +247,30 @@ class BasicAuthenticateTest extends CakeTestCase {
$this->assertEquals($expected, $result);
}
/**
* test userFields and related models success
*
* @return void
*/
public function testAuthenticateUserFieldsRelatedModelsSuccess() {
$User = ClassRegistry::init('User');
$User->bindModel(array('hasOne' => array('Article')));
$this->auth->settings['recursive'] = 0;
$this->auth->settings['userFields'] = array('Article.id', 'Article.title');
$request = new CakeRequest('posts/index', false);
$request->addParams(array('pass' => array(), 'named' => array()));
$_SERVER['PHP_AUTH_USER'] = 'mariano';
$_SERVER['PHP_AUTH_PW'] = 'password';
$result = $this->auth->authenticate($request, $this->response);
$expected = array(
'id' => 1,
'title' => 'First Article',
);
$this->assertEquals($expected, $result['Article']);
}
/**
* test scope failure.
*