Skip to content

Commit

Permalink
Add test for userFields and related models
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienbarre committed Oct 31, 2014
1 parent f6c7102 commit 6091797
Showing 1 changed file with 24 additions and 0 deletions.
Expand Up @@ -247,6 +247,30 @@ public function testAuthenticateUserFieldsSuccess() {
$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.
*
Expand Down

0 comments on commit 6091797

Please sign in to comment.