Permalink
Browse files

Merge branch 'master' into 2.3

  • Loading branch information...
2 parents afab9f1 + 6286b43 commit 468302b526b2a5367297c568c8a44eec3f73e35c @markstory markstory committed Jul 22, 2012
@@ -23,6 +23,7 @@
App::uses('Sanitize', 'Utility');
App::uses('Router', 'Routing');
App::uses('CakeResponse', 'Network');
+App::uses('Controller', 'Controller');
/**
* Exception Renderer.
View
@@ -88,14 +88,14 @@ class CakeLog {
* @var array
*/
protected static $_defaultLevels = array(
- LOG_EMERG => 'emergency',
- LOG_ALERT => 'alert',
- LOG_CRIT => 'critical',
- LOG_ERR => 'error',
- LOG_WARNING => 'warning',
- LOG_NOTICE => 'notice',
- LOG_INFO => 'info',
- LOG_DEBUG => 'debug',
+ 'emergency' => LOG_EMERG,
+ 'alert' => LOG_ALERT,
+ 'critical' => LOG_CRIT,
+ 'error' => LOG_ERR,
+ 'warning' => LOG_WARNING,
+ 'notice' => LOG_NOTICE,
+ 'info' => LOG_INFO,
+ 'debug' => LOG_DEBUG,
);
/**
@@ -276,8 +276,8 @@ public static function levels($levels = array(), $append = true) {
* @return array default log levels
*/
public static function defaultLevels() {
- self::$_levels = self::$_defaultLevels;
- self::$_levelMap = array_flip(self::$_levels);
+ self::$_levelMap = self::$_defaultLevels;
+ self::$_levels = array_flip(self::$_levelMap);
return self::$_levels;
}
@@ -214,12 +214,12 @@ public function testSelectiveLoggingByLevel() {
}
CakeLog::config('spam', array(
'engine' => 'FileLog',
- 'types' => 'info',
+ 'types' => 'debug',
'file' => 'spam',
));
CakeLog::config('eggs', array(
'engine' => 'FileLog',
- 'types' => array('eggs', 'info', 'error', 'warning'),
+ 'types' => array('eggs', 'debug', 'error', 'warning'),
'file' => 'eggs',
));
@@ -229,13 +229,13 @@ public function testSelectiveLoggingByLevel() {
$this->assertTrue(file_exists(LOGS . 'eggs.log'));
$this->assertFalse(file_exists(LOGS . 'spam.log'));
- CakeLog::write(LOG_INFO, $testMessage);
+ CakeLog::write(LOG_DEBUG, $testMessage);
$this->assertTrue(file_exists(LOGS . 'spam.log'));
$contents = file_get_contents(LOGS . 'spam.log');
- $this->assertContains('Info: ' . $testMessage, $contents);
+ $this->assertContains('Debug: ' . $testMessage, $contents);
$contents = file_get_contents(LOGS . 'eggs.log');
- $this->assertContains('Info: ' . $testMessage, $contents);
+ $this->assertContains('Debug: ' . $testMessage, $contents);
if (file_exists(LOGS . 'spam.log')) {
unlink(LOGS . 'spam.log');
@@ -491,10 +491,10 @@ public function testConvenienceScopedLogging() {
$this->_resetLogConfig();
CakeLog::config('shops', array(
'engine' => 'FileLog',
- 'types' => array('info', 'notice', 'warning'),
+ 'types' => array('info', 'debug', 'notice', 'warning'),
'scopes' => array('transactions', 'orders'),
'file' => 'shops',
- ));
+ ));
CakeLog::info('info message', 'transactions');
$this->assertFalse(file_exists(LOGS . 'error.log'));
@@ -540,14 +540,14 @@ public function testConvenienceMethods() {
$testMessage = 'emergency message';
CakeLog::emergency($testMessage);
$contents = file_get_contents(LOGS . 'error.log');
- $this->assertContains('Emergency: ' . $testMessage, $contents);
+ $this->assertRegExp('/(Emergency|Critical): ' . $testMessage . '/', $contents);
$this->assertFalse(file_exists(LOGS . 'debug.log'));
$this->_deleteLogs();
$testMessage = 'alert message';
CakeLog::alert($testMessage);
$contents = file_get_contents(LOGS . 'error.log');
- $this->assertContains('Alert: ' . $testMessage, $contents);
+ $this->assertRegExp('/(Alert|Critical): ' . $testMessage . '/', $contents);
$this->assertFalse(file_exists(LOGS . 'debug.log'));
$this->_deleteLogs();
@@ -575,14 +575,14 @@ public function testConvenienceMethods() {
$testMessage = 'notice message';
CakeLog::notice($testMessage);
$contents = file_get_contents(LOGS . 'debug.log');
- $this->assertContains('Notice: ' . $testMessage, $contents);
+ $this->assertRegExp('/(Notice|Debug): ' . $testMessage . '/', $contents);
$this->assertFalse(file_exists(LOGS . 'error.log'));
$this->_deleteLogs();
$testMessage = 'info message';
CakeLog::info($testMessage);
$contents = file_get_contents(LOGS . 'debug.log');
- $this->assertContains('Info: ' . $testMessage, $contents);
+ $this->assertRegExp('/(Info|Debug): ' . $testMessage . '/', $contents);
$this->assertFalse(file_exists(LOGS . 'error.log'));
$this->_deleteLogs();
@@ -125,10 +125,14 @@ public function testWrite() {
'Session' => array(
'id' => 'foo',
'data' => 'Some value',
- 'expires' => time() + (Configure::read('Session.timeout') * 60)
)
);
+ $expires = $result['Session']['expires'];
+ unset($result['Session']['expires']);
$this->assertEquals($expected, $result);
+
+ $expected = time() + (Configure::read('Session.timeout') * 60);
+ $this->assertWithinMargin($expires, $expected, 1);
}
/**
@@ -1782,6 +1782,10 @@ public function testUrl() {
$this->assertFalse(Validation::url('www.cakephp.org', true));
$this->assertTrue(Validation::url('http://www.cakephp.org', true));
$this->assertTrue(Validation::url('http://example.com/~userdir/'));
+ $this->assertTrue(Validation::url('http://underscore_subdomain.example.org'));
+ $this->assertTrue(Validation::url('http://_jabber._tcp.gmail.com'));
+ $this->assertFalse(Validation::url('http://www.underscore_domain.org'));
+ $this->assertFalse(Validation::url('http://_jabber._tcp.g_mail.com'));
$this->assertTrue(Validation::url('http://example.com/~userdir/subdir/index.html'));
$this->assertTrue(Validation::url('http://www.zwischenraume.de'));
@@ -38,7 +38,7 @@ class Validation {
* @var array
*/
protected static $_pattern = array(
- 'hostname' => '(?:[a-z0-9][-a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
+ 'hostname' => '(?:[-_a-z0-9][-_a-z0-9]*\.)*(?:[a-z0-9][-a-z0-9]{0,62})\.(?:(?:[a-z]{2}\.)?[a-z]{2,4}|museum|travel)'
);
/**

0 comments on commit 468302b

Please sign in to comment.