Fixing validation methods + features lost in [f51ce734] due to a bad

merge.
Fixing additional tests to reflect changes in 2.0
This commit is contained in:
mark_story 2010-12-10 22:51:42 -05:00
parent b9f0fc0724
commit 1e108748e9
4 changed files with 19 additions and 7 deletions

View file

@ -455,7 +455,7 @@ class CakeSession {
}
foreach ($write as $key => $val) {
if (in_array($key, self::$watchKeys)) {
trigger_error(__('Writing session key {%s}: %s', $key, Debugger::exportVar($val)), E_USER_NOTICE);
trigger_error(__('Writing session key {%s}: %s', $key, var_export($val, true)), E_USER_NOTICE);
}
self::__overwrite($_SESSION, Set::insert($_SESSION, $key, $val));
if (Set::classicExtract($_SESSION, $key) !== $val) {

View file

@ -260,7 +260,7 @@ class Scaffold {
if ($this->ScaffoldModel->save($request->data)) {
if ($this->controller->_afterScaffoldSave($action)) {
$message = sprintf(
__('The %1$s has been %2$s', true),
__('The %1$s has been %2$s'),
Inflector::humanize($this->modelKey),
$success
);
@ -328,7 +328,7 @@ class Scaffold {
$message = sprintf(
__('There was an error deleting the %1$s with id: %2$d', true),
Inflector::humanize($this->modelClass), $id
));
);
return $this->_sendMessage($message);
}
} elseif ($this->controller->_scaffoldError('delete') === false) {

View file

@ -670,10 +670,10 @@ class Validation {
self::__populateIp();
$validChars = '([' . preg_quote('!"$&\'()*+,-.@_:;=~') . '\/0-9a-z\p{L}\p{N}]|(%[0-9a-f]{2}))';
$regex = '/^(?:(?:https?|ftps?|file|news|gopher):\/\/)' . (!empty($strict) ? '' : '?') .
'(?:' . self::$__pattern['IPv4'] . '|' . self::$__pattern['hostname'] . ')(?::[1-9][0-9]{0,3})?' .
'(?:' . self::$__pattern['IPv4'] . '|\[' . self::$__pattern['IPv6'] . '\]|' . self::$__pattern['hostname'] . ')(?::[1-9][0-9]{0,4})?' .
'(?:\/?|\/' . $validChars . '*)?' .
'(?:\?' . $validChars . '*)?' .
'(?:#' . $validChars . '*)?$/i';
'(?:#' . $validChars . '*)?$/iu';
return self::_check($check, $regex);
}
@ -701,6 +701,18 @@ class Validation {
return call_user_func_array(array($object, $method), array($check, $args));
}
/**
* Checks that a value is a valid uuid - http://tools.ietf.org/html/rfc4122
*
* @param string $check Value to check
* @return boolean Success
* @access public
*/
public static function uuid($check) {
$regex = '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i';
return self::_check($check, $regex);
}
/**
* Attempts to pass unhandled Validation locales to a class starting with $classPrefix
* and ending with Validation. For example $classPrefix = 'nl', the class would be

View file

@ -465,10 +465,10 @@ class CookieComponentTest extends CakeTestCase {
* @return void
*/
function testNoErrorOnNonArrayData() {
$this->Controller->Cookie->destroy();
$this->Cookie->destroy();
$_COOKIE['CakeTestCookie'] = 'kaboom';
$this->assertNull($this->Controller->Cookie->read('value'));
$this->assertNull($this->Cookie->read('value'));
}
/**