mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 02:26:17 +00:00
adding Object::stop(), updating auth and auth.test to use
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6901 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
3d251e4145
commit
8a236492a0
3 changed files with 38 additions and 30 deletions
|
@ -242,7 +242,7 @@ class AuthComponent extends Object {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if (Configure::read() > 0) {
|
if (Configure::read() > 0) {
|
||||||
uses('debugger');
|
App::import('Debugger');
|
||||||
Debugger::checkSessionKey();
|
Debugger::checkSessionKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -318,6 +318,7 @@ class AuthComponent extends Object {
|
||||||
} elseif (!empty($this->ajaxLogin)) {
|
} elseif (!empty($this->ajaxLogin)) {
|
||||||
$controller->viewPath = 'elements';
|
$controller->viewPath = 'elements';
|
||||||
echo $controller->render($this->ajaxLogin, 'ajax');
|
echo $controller->render($this->ajaxLogin, 'ajax');
|
||||||
|
$this->stop();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -127,6 +127,16 @@ class Object {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Stop execution of the current script
|
||||||
|
*
|
||||||
|
* @param $status see http://php.net/exit for values
|
||||||
|
* @return void
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function stop($status = 0) {
|
||||||
|
exit($status);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* API for logging events.
|
* API for logging events.
|
||||||
*
|
*
|
||||||
|
|
|
@ -30,6 +30,21 @@ App::import(array('controller' . DS . 'components' . DS .'auth', 'controller' .
|
||||||
|
|
||||||
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
|
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
|
||||||
Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
||||||
|
/**
|
||||||
|
* Short description for class.
|
||||||
|
*
|
||||||
|
* @package cake.tests
|
||||||
|
* @subpackage cake.tests.cases.libs.controller.components
|
||||||
|
*/
|
||||||
|
class TestAuthComponent extends AuthComponent {
|
||||||
|
|
||||||
|
var $testStop = false;
|
||||||
|
|
||||||
|
function stop() {
|
||||||
|
$this->testStop = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Short description for class.
|
* Short description for class.
|
||||||
*
|
*
|
||||||
|
@ -106,16 +121,18 @@ class AuthTestController extends Controller {
|
||||||
|
|
||||||
class AjaxAuthController extends Controller {
|
class AjaxAuthController extends Controller {
|
||||||
var $name = 'AjaxAuth';
|
var $name = 'AjaxAuth';
|
||||||
var $components = array('Auth');
|
var $components = array('TestAuth');
|
||||||
var $uses = array();
|
var $uses = array();
|
||||||
var $testUrl = null;
|
var $testUrl = null;
|
||||||
|
|
||||||
function beforeFilter() {
|
function beforeFilter() {
|
||||||
$this->Auth->ajaxLogin = 'test_element';
|
$this->TestAuth->ajaxLogin = 'test_element';
|
||||||
$this->Auth->userModel = 'AuthUser';
|
$this->TestAuth->userModel = 'AuthUser';
|
||||||
}
|
}
|
||||||
function add() {
|
function add() {
|
||||||
echo 'Added Record';
|
if ($this->TestAuth->testStop !== true) {
|
||||||
|
echo 'Added Record';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
function redirect($url, $status, $exit) {
|
function redirect($url, $status, $exit) {
|
||||||
$this->testUrl = Router::url($url);
|
$this->testUrl = Router::url($url);
|
||||||
|
@ -490,37 +507,17 @@ class AuthTest extends CakeTestCase {
|
||||||
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
|
Configure::write('viewPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
|
||||||
$_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest";
|
$_SERVER['HTTP_X_REQUESTED_WITH'] = "XMLHttpRequest";
|
||||||
|
|
||||||
$url = '/auth_test/add';
|
|
||||||
$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->Auth->RequestHandler->startup($this->Controller);
|
|
||||||
$this->Controller->Auth->initialize($this->Controller);
|
|
||||||
|
|
||||||
$this->Controller->Auth->loginAction = array('controller' => 'auth_test', 'action' => 'login');
|
|
||||||
$this->Controller->Auth->userModel = 'AuthUser';
|
|
||||||
|
|
||||||
$this->Controller->Auth->ajaxLogin = 'test_element';
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
$this->Controller->Auth->startup($this->Controller);
|
|
||||||
$result = ob_get_clean();
|
|
||||||
|
|
||||||
$this->assertPattern('/test element/', $result);
|
|
||||||
$this->assertNoPattern('/add/', $result);
|
|
||||||
|
|
||||||
if (!class_exists('dispatcher')) {
|
if (!class_exists('dispatcher')) {
|
||||||
require CAKE . 'dispatcher.php';
|
require CAKE . 'dispatcher.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
Configure::write('test', true);
|
Configure::write('test', true);
|
||||||
ob_start();
|
ob_start();
|
||||||
$Dispatcher =& new Dispatcher();
|
$Dispatcher =& new Dispatcher();
|
||||||
$Dispatcher->dispatch('/ajax_auth/add', array('return' => 1));
|
$Dispatcher->dispatch('/ajax_auth/add', array('return' => 1));
|
||||||
$result = ob_get_clean();
|
$result = ob_get_clean();
|
||||||
$this->assertPattern('/test element/', $result);
|
$this->assertPattern('/test element/', $result);
|
||||||
$this->assertNoPattern('/Added Record/', $result);
|
$this->assertNoPattern('/Added Record/', $result);
|
||||||
|
|
||||||
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue