From ddc047751cb6e247056a2c869b15b45a8f506f1f Mon Sep 17 00:00:00 2001 From: mark_story Date: Mon, 2 Feb 2009 02:58:15 +0000 Subject: [PATCH] Adding submitted test cases from harking Closes #6047 git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8013 3807eeeb-6ff5-0310-8944-8be069107fe0 --- .../libs/controller/components/auth.test.php | 55 ++++++++++++++- .../auth_user_custom_field_fixture.php | 70 +++++++++++++++++++ 2 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 cake/tests/fixtures/auth_user_custom_field_fixture.php diff --git a/cake/tests/cases/libs/controller/components/auth.test.php b/cake/tests/cases/libs/controller/components/auth.test.php index e53f7c7da..5dcc9d6f0 100644 --- a/cake/tests/cases/libs/controller/components/auth.test.php +++ b/cake/tests/cases/libs/controller/components/auth.test.php @@ -122,6 +122,21 @@ class AuthUser extends CakeTestModel { * @package cake.tests * @subpackage cake.tests.cases.libs.controller.components */ +class AuthUserCustomField extends AuthUser{ +/** + * name property + * + * @var string 'AuthUser' + * @access public + */ + var $name = 'AuthUserCustomField'; +} +/** +* Short description for class. +* +* @package cake.tests +* @subpackage cake.tests.cases.libs.controller.components +*/ class UuidUser extends CakeTestModel { /** * name property @@ -398,7 +413,7 @@ class AuthTest extends CakeTestCase { * @var array * @access public */ - var $fixtures = array('core.uuid', 'core.auth_user', 'core.aro', 'core.aco', 'core.aros_aco', 'core.aco_action'); + var $fixtures = array('core.uuid', 'core.auth_user', 'core.auth_user_custom_field', 'core.aro', 'core.aco', 'core.aros_aco', 'core.aco_action'); /** * initialized property * @@ -985,6 +1000,42 @@ class AuthTest extends CakeTestCase { $user = $this->Controller->Auth->user(); $this->assertTrue(!!$user); } + +/** + * testCustomField method + * + * @access public + * @return void + */ + function testCustomField() { + Router::reload(); + + $this->AuthUserCustomField =& new AuthUserCustomField(); + $user = array( + 'id' => 1, 'email' => 'harking@example.com', + 'password' => Security::hash(Configure::read('Security.salt') . 'cake' + )); + $user = $this->AuthUserCustomField->save($user, false); + + Router::connect('/', array('controller' => 'people', 'action' => 'login')); + $url = '/'; + $this->Controller->params = Router::parse($url); + Router::setRequestInfo(array($this->Controller->passedArgs, array( + 'base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), + 'argSeparator' => ':', 'namedArgs' => array() + ))); + $this->Controller->data['AuthUserCustomField'] = array('email' => 'harking@example.com', 'password' => 'cake'); + $this->Controller->params['url']['url'] = substr($url, 1); + $this->Controller->Auth->initialize($this->Controller); + $this->Controller->Auth->fields = array('username' => 'email', 'password' => 'password'); + $this->Controller->Auth->loginAction = array('controller' => 'people', 'action' => 'login'); + $this->Controller->Auth->userModel = 'AuthUserCustomField'; + + $this->Controller->Auth->startup($this->Controller); + $user = $this->Controller->Auth->user(); + $this->assertTrue(!!$user); + } + /** * testAdminRoute method * @@ -1101,4 +1152,4 @@ class AuthTest extends CakeTestCase { unset($this->Controller, $this->AuthUser); } } -?> \ No newline at end of file +?> diff --git a/cake/tests/fixtures/auth_user_custom_field_fixture.php b/cake/tests/fixtures/auth_user_custom_field_fixture.php new file mode 100644 index 000000000..9618d6c1e --- /dev/null +++ b/cake/tests/fixtures/auth_user_custom_field_fixture.php @@ -0,0 +1,70 @@ + + * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) + * + * Licensed under The Open Group Test Suite License + * Redistributions of files must retain the above copyright notice. + * + * @filesource + * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) + * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests + * @package cake.tests + * @subpackage cake.tests.fixtures + * @since CakePHP(tm) v 1.2.1.8013 + * @version $Revision$ + * @modifiedby $LastChangedBy$ + * @lastmodified $Date$ + * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License + */ +/** + * Short description for class. + * + * @package cake.tests + * @subpackage cake.tests.fixtures + */ +class AuthUserCustomFieldFixture extends CakeTestFixture { +/** + * name property + * + * @var string 'AuthUser' + * @access public + */ + var $name = 'AuthUserCustomField'; +/** + * fields property + * + * @var array + * @access public + */ + var $fields = array( + 'id' => array('type' => 'integer', 'key' => 'primary'), + 'email' => array('type' => 'string', 'null' => false), + 'password' => array('type' => 'string', 'null' => false), + 'created' => 'datetime', + 'updated' => 'datetime' + ); +/** + * records property + * + * @var array + * @access public + */ + var $records = array( + array('email' => 'mariano@example.com', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:16:23', 'updated' => '2007-03-17 01:18:31'), + array('email' => 'nate@example.com', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:18:23', 'updated' => '2007-03-17 01:20:31'), + array('email' => 'larry@example.com', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:20:23', 'updated' => '2007-03-17 01:22:31'), + array('email' => 'garrett@example.com', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'), + array('email' => 'chartjes@example.com', 'password' => '5f4dcc3b5aa765d61d8327deb882cf99', 'created' => '2007-03-17 01:22:23', 'updated' => '2007-03-17 01:24:31'), + + ); +} + +?>