mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
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:
parent
032faec107
commit
2558705e14
1 changed files with 42 additions and 2 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue