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); define('CONFIGS', APP.'config'.DS);
} }
/**
* Path to the libs directory.
*/
define('INFLECTIONS', CAKE.'config'.DS.'inflections'.DS);
/** /**
* Path to the libs directory. * Path to the libs directory.
*/ */
@ -197,13 +192,6 @@ if (!defined('VENDORS')) {
define('VENDORS', CAKE_CORE_INCLUDE_PATH.DS.'vendors'.DS); 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 * Full url prefix
*/ */

View file

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

View file

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

View file

@ -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;
} }

View file

@ -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.
* *

View file

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

File diff suppressed because it is too large Load diff

View file

@ -28,24 +28,6 @@
*/ */
class String { 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 * Generate a random UUID
* *

View file

@ -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();
} }

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 * 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 * @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 * @access public
*/ */
function toList($list, $and = 'and') { function toList($list, $and = 'and', $separator = ', ') {
$return = ''; return implode($separator, array_slice($list, null, -1)) . ' ' . $and . ' ' . array_pop($list);
$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;
} }
} }
?> ?>

View file

@ -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);

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(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'), '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'), 'No vendors shells dir %s');
$this->assertTrue(is_dir($path . DS . 'vendors' . DS . 'shells' . DS . 'tasks'), 'No vendors shells tasks 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(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 . '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'; $file = $path . DS . 'bake_test_plugin_app_controller.php';
$this->Task->expectAt(0, 'createFile', array($file, '*'), 'No AppController %s'); $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 . '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 . '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 . '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 . '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 . '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'); $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 * testBadAssertTags
* *
* @access public * @access public

View file

@ -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);
} }

View file

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

File diff suppressed because it is too large Load diff

View file

@ -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'));
} }
/** /**

View file

@ -363,8 +363,14 @@ class TextHelperTest extends CakeTestCase {
$result = $this->Text->toList(array('Dusty', 'Lucky', 'Ned'), 'y'); $result = $this->Text->toList(array('Dusty', 'Lucky', 'Ned'), 'y');
$this->assertEqual($result, 'Dusty, Lucky y Ned'); $this->assertEqual($result, 'Dusty, Lucky y Ned');
$result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y'); $result = $this->Text->toList(array( 1 => 'Dusty', 2 => 'Lucky', 3 => 'Ned'), 'y');
$this->assertEqual($result, 'Dusty, Lucky y Ned'); $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() { function testUUIDGeneration() {
$result = $this->View->uuid('form', array('controller' => 'posts', 'action' => 'index')); $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')); $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')); $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); 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
* *

View file

@ -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());

View file

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