Merge branch '1.3-misc' into 1.3-router

This commit is contained in:
mark_story 2009-12-03 19:13:28 -05:00
commit aff7d61277
11 changed files with 105 additions and 55 deletions

View file

@ -429,6 +429,9 @@ class SecurityComponent extends Object {
* @access protected
*/
function _requireMethod($method, $actions = array()) {
if (isset($actions[0]) && is_array($actions[0])) {
$actions = $actions[0];
}
$this->{'require' . $method} = (empty($actions)) ? array('*'): $actions;
}

View file

@ -48,14 +48,6 @@ class SessionComponent extends CakeSession {
*/
var $__started = false;
/**
* Used to determine if request are from an Ajax request
*
* @var boolean
* @access private
*/
var $__bare = 0;
/**
* 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.
*

View file

@ -782,11 +782,13 @@ class Validation extends Object {
$_this->regex = '/\\A\\b[0-9]{9}\\b\\z/i';
break;
case 'us':
default:
$_this->regex = '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i';
break;
}
}
if (empty($_this->regex)) {
return $_this->_pass('ssn', $check, $country);
}
return $_this->_check();
}

View file

@ -686,13 +686,16 @@ class View extends Object {
for ($i = count($helpers) - 1; $i >= 0; $i--) {
$name = $helperNames[$i];
$helper =& $loadedHelpers[$helpers[$i]];
${$name} =& $loadedHelpers[$helpers[$i]];
$this->loaded[$helperNames[$i]] =& ${$name};
$this->{$helpers[$i]} =& ${$name};
if (!isset($___dataForView[$name])) {
${$name} =& $helper;
}
$this->loaded[$helperNames[$i]] =& $helper;
$this->{$helpers[$i]} =& $helper;
}
$this->_triggerHelpers('beforeRender');
unset($name, $loadedHelpers, $helpers, $i, $helperNames);
unset($name, $loadedHelpers, $helpers, $i, $helperNames, $helper);
}
extract($___dataForView, EXTR_SKIP);

View file

@ -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
*
* @access public

View file

@ -190,7 +190,7 @@ class SecurityComponentTest extends CakeTestCase {
function testRequirePostFail() {
$_SERVER['REQUEST_METHOD'] = 'GET';
$this->Controller->action = 'posted';
$this->Controller->Security->requirePost('posted');
$this->Controller->Security->requirePost(array('posted'));
$this->Controller->Security->startup($this->Controller);
$this->assertTrue($this->Controller->failed);
}
@ -219,7 +219,7 @@ class SecurityComponentTest extends CakeTestCase {
$_SERVER['HTTPS'] = 'off';
$_SERVER['REQUEST_METHOD'] = 'POST';
$this->Controller->action = 'posted';
$this->Controller->Security->requireSecure('posted');
$this->Controller->Security->requireSecure(array('posted'));
$this->Controller->Security->startup($this->Controller);
$this->assertTrue($this->Controller->failed);
}
@ -249,7 +249,7 @@ class SecurityComponentTest extends CakeTestCase {
$_SERVER['REQUEST_METHOD'] = 'AUTH';
$this->Controller->action = 'posted';
$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->assertTrue($this->Controller->failed);
@ -321,7 +321,7 @@ class SecurityComponentTest extends CakeTestCase {
function testRequireGetFail() {
$_SERVER['REQUEST_METHOD'] = 'POST';
$this->Controller->action = 'getted';
$this->Controller->Security->requireGet('getted');
$this->Controller->Security->requireGet(array('getted'));
$this->Controller->Security->startup($this->Controller);
$this->assertTrue($this->Controller->failed);
}
@ -360,7 +360,7 @@ class SecurityComponentTest extends CakeTestCase {
$this->Controller->action = 'posted';
$this->Controller->Security->requireLogin(
'posted',
array('posted'),
array('type' => 'basic', 'users' => array('admin' => 'password'))
);
$_SERVER['PHP_AUTH_USER'] = 'admin2';
@ -437,7 +437,7 @@ DIGEST;
function testRequirePutFail() {
$_SERVER['REQUEST_METHOD'] = 'POST';
$this->Controller->action = 'putted';
$this->Controller->Security->requirePut('putted');
$this->Controller->Security->requirePut(array('putted'));
$this->Controller->Security->startup($this->Controller);
$this->assertTrue($this->Controller->failed);
}
@ -479,7 +479,7 @@ DIGEST;
function testRequireDeleteFail() {
$_SERVER['REQUEST_METHOD'] = 'POST';
$this->Controller->action = 'deleted';
$this->Controller->Security->requireDelete('deleted');
$this->Controller->Security->requireDelete(array('deleted', 'other_method'));
$this->Controller->Security->startup($this->Controller);
$this->assertTrue($this->Controller->failed);
}

View file

@ -136,26 +136,6 @@ class SessionComponentTest extends CakeTestCase {
$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
*

View file

@ -58,10 +58,18 @@ class TestNlValidation {
function postal($check) {
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
*
@ -2041,9 +2049,10 @@ class ValidationTest extends CakeTestCase {
*
* @return void
*/
function testPhoneAndPostalPass() {
function testPhonePostalSsnPass() {
$this->assertTrue(Validation::postal('text', null, 'testNl'));
$this->assertTrue(Validation::phone('text', null, 'testDe'));
$this->assertTrue(Validation::ssn('text', null, 'testNl'));
}
/**

View file

@ -719,6 +719,23 @@ class ViewTest extends CakeTestCase {
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
*

View file

@ -586,6 +586,9 @@ class CakeTestCase extends UnitTestCase {
}
$i = 0;
foreach ($normalized as $tags) {
if (!is_array($tags)) {
$tags = (string)$tags;
}
$i++;
if (is_string($tags) && $tags{0} == '<') {
$tags = array(substr($tags, 1) => array());

View file

@ -0,0 +1,4 @@
<?php
echo $html;
echo $this->Html->link('Test link', '#');
?>