diff --git a/cake/libs/controller/components/security.php b/cake/libs/controller/components/security.php index 9b64930a6..e9937663a 100644 --- a/cake/libs/controller/components/security.php +++ b/cake/libs/controller/components/security.php @@ -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; } diff --git a/cake/libs/controller/components/session.php b/cake/libs/controller/components/session.php index bcf0dc6f3..cc4820c4b 100644 --- a/cake/libs/controller/components/session.php +++ b/cake/libs/controller/components/session.php @@ -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. * diff --git a/cake/libs/validation.php b/cake/libs/validation.php index 73a90fe33..c6fde1e76 100644 --- a/cake/libs/validation.php +++ b/cake/libs/validation.php @@ -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(); } diff --git a/cake/libs/view/view.php b/cake/libs/view/view.php index 854bcc1e5..701e21044 100644 --- a/cake/libs/view/view.php +++ b/cake/libs/view/view.php @@ -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); diff --git a/cake/tests/cases/libs/cake_test_case.test.php b/cake/tests/cases/libs/cake_test_case.test.php index 5260420a8..a9c472f28 100644 --- a/cake/tests/cases/libs/cake_test_case.test.php +++ b/cake/tests/cases/libs/cake_test_case.test.php @@ -164,6 +164,56 @@ class CakeTestCaseTest extends CakeTestCase { } /** + * testNumericValuesInExpectationForAssertTags + * + * @access public + * @return void + */ + function testNumericValuesInExpectationForAssertTags() { + $value = 220985; + + $input = '

' . $value . '

'; + $pattern = array( + 'assertTrue($this->Case->assertTags($input, $pattern)); + + $input = '

' . $value . '

' . $value . '

'; + $pattern = array( + 'assertTrue($this->Case->assertTags($input, $pattern)); + + $input = '

' . $value . '

' . $value . '

'; + $pattern = array( + ' array('id' => $value), + 'assertTrue($this->Case->assertTags($input, $pattern)); + } + + /** * testBadAssertTags * * @access public diff --git a/cake/tests/cases/libs/controller/components/security.test.php b/cake/tests/cases/libs/controller/components/security.test.php index a704dd183..d0973e23b 100644 --- a/cake/tests/cases/libs/controller/components/security.test.php +++ b/cake/tests/cases/libs/controller/components/security.test.php @@ -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); } diff --git a/cake/tests/cases/libs/controller/components/session.test.php b/cake/tests/cases/libs/controller/components/session.test.php index ce33e280d..445e8fd03 100644 --- a/cake/tests/cases/libs/controller/components/session.test.php +++ b/cake/tests/cases/libs/controller/components/session.test.php @@ -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 * diff --git a/cake/tests/cases/libs/validation.test.php b/cake/tests/cases/libs/validation.test.php index 5e76b9b76..f1af0ce8b 100644 --- a/cake/tests/cases/libs/validation.test.php +++ b/cake/tests/cases/libs/validation.test.php @@ -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')); } /** diff --git a/cake/tests/cases/libs/view/view.test.php b/cake/tests/cases/libs/view/view.test.php index 6f52101f2..c0b7e99eb 100644 --- a/cake/tests/cases/libs/view/view.test.php +++ b/cake/tests/cases/libs/view/view.test.php @@ -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 * diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index 8e4dd0c7f..3983e84e3 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -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()); diff --git a/cake/tests/test_app/views/posts/helper_overwrite.ctp b/cake/tests/test_app/views/posts/helper_overwrite.ctp new file mode 100644 index 000000000..a3b6928fb --- /dev/null +++ b/cake/tests/test_app/views/posts/helper_overwrite.ctp @@ -0,0 +1,4 @@ +Html->link('Test link', '#'); +?> \ No newline at end of file