Merge branch 'mergers' into 1.2-merger

Conflicts:
	cake/libs/view/helpers/text.php
	cake/tests/cases/libs/view/helpers/text.test.php
This commit is contained in:
mark_story 2009-12-06 22:03:17 -05:00
commit 24b636cc71
25 changed files with 1402 additions and 969 deletions

View file

@ -99,11 +99,6 @@ if (!defined('CONFIGS')) {
define('CONFIGS', APP.'config'.DS);
}
/**
* Path to the libs directory.
*/
define('INFLECTIONS', CAKE.'config'.DS.'inflections'.DS);
/**
* Path to the libs directory.
*/
@ -197,13 +192,6 @@ if (!defined('VENDORS')) {
define('VENDORS', CAKE_CORE_INCLUDE_PATH.DS.'vendors'.DS);
}
/**
* Path to the Pear directory
* The purporse is to make it easy porting Pear libs into Cake
* without setting the include_path PHP variable.
*/
define('PEAR', VENDORS.'Pear'.DS);
/**
* Full url prefix
*/

View file

@ -153,10 +153,9 @@ class PluginTask extends Shell {
'tests' . DS . 'cases' . DS . 'models',
'tests' . DS . 'groups',
'tests' . DS . 'fixtures',
'vendors' . DS . 'img',
'vendors' . DS . 'js',
'vendors' . DS . 'css',
'vendors' . DS . 'shells' . DS . 'tasks'
'vendors',
'vendors' . DS . 'shells' . DS . 'tasks',
'webroot'
);
foreach ($directories as $directory) {

View file

@ -61,14 +61,6 @@ class Dispatcher extends Object {
*/
var $here = false;
/**
* Admin route (if on it)
*
* @var string
* @access public
*/
var $admin = false;
/**
* Plugin being served (if any)
*
@ -293,7 +285,7 @@ class Dispatcher extends Object {
$params['action'] = 'index';
}
if (isset($params['form']['data'])) {
$params['data'] = Router::stripEscape($params['form']['data']);
$params['data'] = $params['form']['data'];
unset($params['form']['data']);
}
if (isset($_GET)) {

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

@ -1933,7 +1933,7 @@ class DboSource extends DataSource {
} else {
$data = $this->__quoteFields($key) . ' IN (';
}
if ($quoteValues || strpos($value[0], '-!') !== 0) {
if ($quoteValues) {
if (is_object($model)) {
$columnType = $model->getColumnType($key);
}

File diff suppressed because it is too large Load diff

View file

@ -28,24 +28,6 @@
*/
class String {
/**
* Gets a reference to the String object instance
*
* @return object String instance
* @access public
* @static
* @deprecated
*/
function &getInstance() {
trigger_error('String::getInstance() is deprecated. All String methods are called statically.', E_USER_WARNING);
static $instance = array();
if (!$instance) {
$instance[0] =& new String();
}
return $instance[0];
}
/**
* Generate a random UUID
*

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

@ -328,21 +328,13 @@ class TextHelper extends AppHelper {
* Creates a comma separated list where the last two items are joined with 'and', forming natural English
*
* @param array $list The list to be joined
* @return string
* @param string $and The word used to join the last and second last items together with. Defaults to 'and'
* @param string $separator The separator used to join all othe other items together. Defaults to ', '
* @return string The glued together string.
* @access public
*/
function toList($list, $and = 'and') {
$return = '';
$count = count($list) - 1;
$counter = 0;
foreach ($list as $i => $item) {
$return .= $item;
if ($count > 0 && $counter < $count) {
$return .= ($counter < $count - 1 ? ', ' : " {$and} ");
}
$counter++;
}
return $return;
function toList($list, $and = 'and', $separator = ', ') {
return implode($separator, array_slice($list, null, -1)) . ' ' . $and . ' ' . array_pop($list);
}
}
?>

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

@ -171,19 +171,12 @@ class PluginTaskTest extends CakeTestCase {
$this->assertTrue(file_exists($path . DS . 'tests' . DS . 'fixtures' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'vendors'), 'No vendors dir %s');
$this->assertTrue(is_dir($path . DS . 'vendors' . DS . 'css'), 'No vendors css dir %s');
$this->assertTrue(file_exists($path . DS . 'vendors' . DS . 'css' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'vendors' . DS . 'js'), 'No vendors js dir %s');
$this->assertTrue(file_exists($path . DS . 'vendors' . DS . 'js' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'vendors' . DS . 'img'), 'No vendors img dir %s');
$this->assertTrue(file_exists($path . DS . 'vendors' . DS . 'img' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'vendors' . DS . 'shells'), 'No vendors shells dir %s');
$this->assertTrue(is_dir($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks'), 'No vendors shells tasks dir %s');
$this->assertTrue(file_exists($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . 'empty'), 'No empty file %s');
$this->assertTrue(is_dir($path . DS . 'libs'), 'No libs dir %s');
$this->assertTrue(is_dir($path . DS . 'webroot'), 'No webroot dir %s');
$file = $path . DS . 'bake_test_plugin_app_controller.php';
$this->Task->expectAt(0, 'createFile', array($file, '*'), 'No AppController %s');

View file

@ -150,9 +150,6 @@ class ProjectTaskTest extends CakeTestCase {
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'cases' . DS . 'shells' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'fixtures' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'tests' . DS . 'groups' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'css' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'img' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'js' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'views' . DS . 'errors' . DS . 'empty'), 'No empty file in dir %s');
$this->assertTrue(is_file($path . DS . 'views' . DS . 'helpers' . DS . 'empty'), 'No empty file in dir %s');

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
*

File diff suppressed because it is too large Load diff

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

@ -363,8 +363,14 @@ class TextHelperTest extends CakeTestCase {
$result = $this->Text->toList(array('Dusty', 'Lucky', 'Ned'), 'y');
$this->assertEqual($result, 'Dusty, Lucky y Ned');
$result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y');
$this->assertEqual($result, 'Dusty, Lucky y Ned');
$result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y');
$this->assertEqual($result, 'Dusty, Lucky y Ned');
$result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'and', ' + ');
$this->assertEqual($result, 'Dusty + Lucky and Ned');
$result = $this->Text->toList(array( 'name1' => 'Dusty', 'name2' => 'Lucky'));
$this->assertEqual($result, 'Dusty and Lucky');
}
}
?>

View file

@ -445,11 +445,11 @@ class ViewTest extends CakeTestCase {
*/
function testUUIDGeneration() {
$result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index'));
$this->assertEqual($result, 'form0425fe3bad');
$this->assertEqual($result, 'form5988016017');
$result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index'));
$this->assertEqual($result, 'forma9918342a7');
$this->assertEqual($result, 'formc3dc6be854');
$result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index'));
$this->assertEqual($result, 'form3ecf2e3e96');
$this->assertEqual($result, 'form28f92cc87f');
}
/**
@ -726,6 +726,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', '#');
?>