From 60917974bfa5da328a814f05b81069a978cebd52 Mon Sep 17 00:00:00 2001 From: Sebastien Barre Date: Fri, 31 Oct 2014 16:35:55 -0400 Subject: [PATCH] Add test for userFields and related models --- .../Component/Auth/BasicAuthenticateTest.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php index 050db008c..8de0858fe 100644 --- a/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php +++ b/lib/Cake/Test/Case/Controller/Component/Auth/BasicAuthenticateTest.php @@ -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. *