mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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
This commit is contained in:
parent
2da0c208d5
commit
ddc047751c
2 changed files with 123 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
70
cake/tests/fixtures/auth_user_custom_field_fixture.php
vendored
Normal file
70
cake/tests/fixtures/auth_user_custom_field_fixture.php
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
/**
|
||||
* Short description for file.
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
||||
* 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'),
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue