mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Add test for userFields and related models
This commit is contained in:
parent
f6c71024c5
commit
60917974bf
1 changed files with 24 additions and 0 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue