closes #4708, test case added to show Auth supports routed login actions

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6997 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
gwoo 2008-05-21 23:45:58 +00:00
parent 032faec107
commit 2558705e14

View file

@ -489,8 +489,17 @@ class AuthTest extends CakeTestCase {
$url = '/admin/something';
$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->params['url']['url'] = ltrim($url, '/');
Router::setRequestInfo(array(
array(
'pass' => array(), 'action' => 'index', 'plugin' => null, 'controller' => 'something',
'admin' => true, 'url' => array('url' => $this->Controller->params['url']['url']),
),
array(
'base' => null, 'here' => $url,
'webroot' => '/', 'passedArgs' => array(),
)
));
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('admin' => true, 'controller' => 'auth_test', 'action' => 'login');
@ -520,6 +529,37 @@ class AuthTest extends CakeTestCase {
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
}
function testLoginActionRedirect() {
Router::reload();
$admin = Configure::read('Routing.admin');
Configure::write('Routing.admin', 'admin');
$url = '/admin/auth_test/login';
$this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = ltrim($url, '/');
Router::setRequestInfo(array(
array(
'pass' => array(), 'action' => 'admin_login', 'plugin' => null, 'controller' => 'auth_test',
'admin' => true, 'url' => array('url' => $this->Controller->params['url']['url']),
),
array(
'base' => null, 'here' => $url,
'webroot' => '/', 'passedArgs' => array(),
)
));
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('admin' => true, 'controller' => 'auth_test', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';
$this->Controller->Auth->startup($this->Controller);
$this->assertNull($this->Controller->testUrl);
Configure::write('Routing.admin', $admin);
}
function tearDown() {
unset($this->Controller, $this->AuthUser);
}