mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-03-18 23:49:55 +00:00
Merge branch '1.3-misc' into 1.3-router
This commit is contained in:
commit
aff7d61277
11 changed files with 105 additions and 55 deletions
|
@ -429,6 +429,9 @@ class SecurityComponent extends Object {
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function _requireMethod($method, $actions = array()) {
|
function _requireMethod($method, $actions = array()) {
|
||||||
|
if (isset($actions[0]) && is_array($actions[0])) {
|
||||||
|
$actions = $actions[0];
|
||||||
|
}
|
||||||
$this->{'require' . $method} = (empty($actions)) ? array('*'): $actions;
|
$this->{'require' . $method} = (empty($actions)) ? array('*'): $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,14 +48,6 @@ class SessionComponent extends CakeSession {
|
||||||
*/
|
*/
|
||||||
var $__started = false;
|
var $__started = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to determine if request are from an Ajax request
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
* @access private
|
|
||||||
*/
|
|
||||||
var $__bare = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class constructor
|
* Class constructor
|
||||||
*
|
*
|
||||||
|
@ -69,19 +61,6 @@ class SessionComponent extends CakeSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the component, gets a reference to Controller::$param['bare'].
|
|
||||||
*
|
|
||||||
* @param object $controller A reference to the controller
|
|
||||||
* @return void
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
function initialize(&$controller) {
|
|
||||||
if (isset($controller->params['bare'])) {
|
|
||||||
$this->__bare = $controller->params['bare'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startup method.
|
* Startup method.
|
||||||
*
|
*
|
||||||
|
|
|
@ -782,11 +782,13 @@ class Validation extends Object {
|
||||||
$_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i';
|
$_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i';
|
||||||
break;
|
break;
|
||||||
case 'us':
|
case 'us':
|
||||||
default:
|
|
||||||
$_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
|
$_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (empty($_this->regex)) {
|
||||||
|
return $_this->_pass('ssn', $check, $country);
|
||||||
|
}
|
||||||
return $_this->_check();
|
return $_this->_check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -686,13 +686,16 @@ class View extends Object {
|
||||||
|
|
||||||
for ($i = count($helpers) - 1; $i >= 0; $i--) {
|
for ($i = count($helpers) - 1; $i >= 0; $i--) {
|
||||||
$name = $helperNames[$i];
|
$name = $helperNames[$i];
|
||||||
|
$helper =& $loadedHelpers[$helpers[$i]];
|
||||||
|
|
||||||
${$name} =& $loadedHelpers[$helpers[$i]];
|
if (!isset($___dataForView[$name])) {
|
||||||
$this->loaded[$helperNames[$i]] =& ${$name};
|
${$name} =& $helper;
|
||||||
$this->{$helpers[$i]} =& ${$name};
|
}
|
||||||
|
$this->loaded[$helperNames[$i]] =& $helper;
|
||||||
|
$this->{$helpers[$i]} =& $helper;
|
||||||
}
|
}
|
||||||
$this->_triggerHelpers('beforeRender');
|
$this->_triggerHelpers('beforeRender');
|
||||||
unset($name, $loadedHelpers, $helpers, $i, $helperNames);
|
unset($name, $loadedHelpers, $helpers, $i, $helperNames, $helper);
|
||||||
}
|
}
|
||||||
|
|
||||||
extract($___dataForView, EXTR_SKIP);
|
extract($___dataForView, EXTR_SKIP);
|
||||||
|
|
|
@ -164,6 +164,56 @@ class CakeTestCaseTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* testNumericValuesInExpectationForAssertTags
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testNumericValuesInExpectationForAssertTags() {
|
||||||
|
$value = 220985;
|
||||||
|
|
||||||
|
$input = '<p><strong>' . $value . '</strong></p>';
|
||||||
|
$pattern = array(
|
||||||
|
'<p',
|
||||||
|
'<strong',
|
||||||
|
$value,
|
||||||
|
'/strong',
|
||||||
|
'/p'
|
||||||
|
);
|
||||||
|
$this->assertTrue($this->Case->assertTags($input, $pattern));
|
||||||
|
|
||||||
|
$input = '<p><strong>' . $value . '</strong></p><p><strong>' . $value . '</strong></p>';
|
||||||
|
$pattern = array(
|
||||||
|
'<p',
|
||||||
|
'<strong',
|
||||||
|
$value,
|
||||||
|
'/strong',
|
||||||
|
'/p',
|
||||||
|
'<p',
|
||||||
|
'<strong',
|
||||||
|
$value,
|
||||||
|
'/strong',
|
||||||
|
'/p',
|
||||||
|
);
|
||||||
|
$this->assertTrue($this->Case->assertTags($input, $pattern));
|
||||||
|
|
||||||
|
$input = '<p><strong>' . $value . '</strong></p><p id="' . $value . '"><strong>' . $value . '</strong></p>';
|
||||||
|
$pattern = array(
|
||||||
|
'<p',
|
||||||
|
'<strong',
|
||||||
|
$value,
|
||||||
|
'/strong',
|
||||||
|
'/p',
|
||||||
|
'p' => array('id' => $value),
|
||||||
|
'<strong',
|
||||||
|
$value,
|
||||||
|
'/strong',
|
||||||
|
'/p',
|
||||||
|
);
|
||||||
|
$this->assertTrue($this->Case->assertTags($input, $pattern));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
* testBadAssertTags
|
* testBadAssertTags
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
|
|
|
@ -190,7 +190,7 @@ class SecurityComponentTest extends CakeTestCase {
|
||||||
function testRequirePostFail() {
|
function testRequirePostFail() {
|
||||||
$_SERVER['REQUEST_METHOD'] = 'GET';
|
$_SERVER['REQUEST_METHOD'] = 'GET';
|
||||||
$this->Controller->action = 'posted';
|
$this->Controller->action = 'posted';
|
||||||
$this->Controller->Security->requirePost('posted');
|
$this->Controller->Security->requirePost(array('posted'));
|
||||||
$this->Controller->Security->startup($this->Controller);
|
$this->Controller->Security->startup($this->Controller);
|
||||||
$this->assertTrue($this->Controller->failed);
|
$this->assertTrue($this->Controller->failed);
|
||||||
}
|
}
|
||||||
|
@ -219,7 +219,7 @@ class SecurityComponentTest extends CakeTestCase {
|
||||||
$_SERVER['HTTPS'] = 'off';
|
$_SERVER['HTTPS'] = 'off';
|
||||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||||
$this->Controller->action = 'posted';
|
$this->Controller->action = 'posted';
|
||||||
$this->Controller->Security->requireSecure('posted');
|
$this->Controller->Security->requireSecure(array('posted'));
|
||||||
$this->Controller->Security->startup($this->Controller);
|
$this->Controller->Security->startup($this->Controller);
|
||||||
$this->assertTrue($this->Controller->failed);
|
$this->assertTrue($this->Controller->failed);
|
||||||
}
|
}
|
||||||
|
@ -249,7 +249,7 @@ class SecurityComponentTest extends CakeTestCase {
|
||||||
$_SERVER['REQUEST_METHOD'] = 'AUTH';
|
$_SERVER['REQUEST_METHOD'] = 'AUTH';
|
||||||
$this->Controller->action = 'posted';
|
$this->Controller->action = 'posted';
|
||||||
$this->Controller->data = array('username' => 'willy', 'password' => 'somePass');
|
$this->Controller->data = array('username' => 'willy', 'password' => 'somePass');
|
||||||
$this->Controller->Security->requireAuth('posted');
|
$this->Controller->Security->requireAuth(array('posted'));
|
||||||
$this->Controller->Security->startup($this->Controller);
|
$this->Controller->Security->startup($this->Controller);
|
||||||
$this->assertTrue($this->Controller->failed);
|
$this->assertTrue($this->Controller->failed);
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ class SecurityComponentTest extends CakeTestCase {
|
||||||
function testRequireGetFail() {
|
function testRequireGetFail() {
|
||||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||||
$this->Controller->action = 'getted';
|
$this->Controller->action = 'getted';
|
||||||
$this->Controller->Security->requireGet('getted');
|
$this->Controller->Security->requireGet(array('getted'));
|
||||||
$this->Controller->Security->startup($this->Controller);
|
$this->Controller->Security->startup($this->Controller);
|
||||||
$this->assertTrue($this->Controller->failed);
|
$this->assertTrue($this->Controller->failed);
|
||||||
}
|
}
|
||||||
|
@ -360,7 +360,7 @@ class SecurityComponentTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Controller->action = 'posted';
|
$this->Controller->action = 'posted';
|
||||||
$this->Controller->Security->requireLogin(
|
$this->Controller->Security->requireLogin(
|
||||||
'posted',
|
array('posted'),
|
||||||
array('type' => 'basic', 'users' => array('admin' => 'password'))
|
array('type' => 'basic', 'users' => array('admin' => 'password'))
|
||||||
);
|
);
|
||||||
$_SERVER['PHP_AUTH_USER'] = 'admin2';
|
$_SERVER['PHP_AUTH_USER'] = 'admin2';
|
||||||
|
@ -437,7 +437,7 @@ DIGEST;
|
||||||
function testRequirePutFail() {
|
function testRequirePutFail() {
|
||||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||||
$this->Controller->action = 'putted';
|
$this->Controller->action = 'putted';
|
||||||
$this->Controller->Security->requirePut('putted');
|
$this->Controller->Security->requirePut(array('putted'));
|
||||||
$this->Controller->Security->startup($this->Controller);
|
$this->Controller->Security->startup($this->Controller);
|
||||||
$this->assertTrue($this->Controller->failed);
|
$this->assertTrue($this->Controller->failed);
|
||||||
}
|
}
|
||||||
|
@ -479,7 +479,7 @@ DIGEST;
|
||||||
function testRequireDeleteFail() {
|
function testRequireDeleteFail() {
|
||||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||||
$this->Controller->action = 'deleted';
|
$this->Controller->action = 'deleted';
|
||||||
$this->Controller->Security->requireDelete('deleted');
|
$this->Controller->Security->requireDelete(array('deleted', 'other_method'));
|
||||||
$this->Controller->Security->startup($this->Controller);
|
$this->Controller->Security->startup($this->Controller);
|
||||||
$this->assertTrue($this->Controller->failed);
|
$this->assertTrue($this->Controller->failed);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,26 +136,6 @@ class SessionComponentTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* testSessionInitialize method
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
function testSessionInitialize() {
|
|
||||||
$Session =& new SessionComponent();
|
|
||||||
|
|
||||||
$this->assertEqual($Session->__bare, 0);
|
|
||||||
|
|
||||||
$Session->initialize(new SessionTestController());
|
|
||||||
$this->assertEqual($Session->__bare, 0);
|
|
||||||
|
|
||||||
$sessionController =& new SessionTestController();
|
|
||||||
$sessionController->params['bare'] = 1;
|
|
||||||
$Session->initialize($sessionController);
|
|
||||||
$this->assertEqual($Session->__bare, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testSessionActivate method
|
* testSessionActivate method
|
||||||
*
|
*
|
||||||
|
|
|
@ -58,10 +58,18 @@ class TestNlValidation {
|
||||||
function postal($check) {
|
function postal($check) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* ssn function for testing ssn pass through
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function ssn($check) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TestNlValidation class
|
* TestDeValidation class
|
||||||
*
|
*
|
||||||
* Used to test pass through of Validation
|
* Used to test pass through of Validation
|
||||||
*
|
*
|
||||||
|
@ -2041,9 +2049,10 @@ class ValidationTest extends CakeTestCase {
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function testPhoneAndPostalPass() {
|
function testPhonePostalSsnPass() {
|
||||||
$this->assertTrue(Validation::postal('text', null, 'testNl'));
|
$this->assertTrue(Validation::postal('text', null, 'testNl'));
|
||||||
$this->assertTrue(Validation::phone('text', null, 'testDe'));
|
$this->assertTrue(Validation::phone('text', null, 'testDe'));
|
||||||
|
$this->assertTrue(Validation::ssn('text', null, 'testNl'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -719,6 +719,23 @@ class ViewTest extends CakeTestCase {
|
||||||
Configure::write('Cache.check', $_check);
|
Configure::write('Cache.check', $_check);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that view vars can replace the local helper variables
|
||||||
|
* and not overwrite the $this->Helper references
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testViewVarOverwritingLocalHelperVar() {
|
||||||
|
$Controller = new ViewPostsController();
|
||||||
|
$Controller->helpers = array('Html');
|
||||||
|
$Controller->set('html', 'I am some test html');
|
||||||
|
$View = new View($Controller);
|
||||||
|
$result = $View->render('helper_overwrite', false);
|
||||||
|
|
||||||
|
$this->assertPattern('/I am some test html/', $result);
|
||||||
|
$this->assertPattern('/Test link/', $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testGetViewFileName method
|
* testGetViewFileName method
|
||||||
*
|
*
|
||||||
|
|
|
@ -586,6 +586,9 @@ class CakeTestCase extends UnitTestCase {
|
||||||
}
|
}
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($normalized as $tags) {
|
foreach ($normalized as $tags) {
|
||||||
|
if (!is_array($tags)) {
|
||||||
|
$tags = (string)$tags;
|
||||||
|
}
|
||||||
$i++;
|
$i++;
|
||||||
if (is_string($tags) && $tags{0} == '<') {
|
if (is_string($tags) && $tags{0} == '<') {
|
||||||
$tags = array(substr($tags, 1) => array());
|
$tags = array(substr($tags, 1) => array());
|
||||||
|
|
4
cake/tests/test_app/views/posts/helper_overwrite.ctp
Normal file
4
cake/tests/test_app/views/posts/helper_overwrite.ctp
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
<?php
|
||||||
|
echo $html;
|
||||||
|
echo $this->Html->link('Test link', '#');
|
||||||
|
?>
|
Loading…
Add table
Reference in a new issue