Permalink
Browse files

Merge remote-tracking branch 'cakephp/2.2' into 3.0-namespace

  • Loading branch information...
jrbasso committed May 27, 2012
2 parents 57a76bf + 1c0f97e commit cdadaeebb7afbad8cacb6d6c9796b935fc4199a2
View
@@ -582,8 +582,10 @@ public static function load($className) {
$paths[] = $pluginPath . 'Lib' . DS . $package . DS;
$paths[] = $pluginPath . $package . DS;
}
+
+ $normalizedClassName = str_replace('\\', DS, $className);
foreach ($paths as $path) {
- $file = $path . $className . '.php';
+ $file = $path . $normalizedClassName . '.php';
if (file_exists($file)) {
self::_map($file, $className, $plugin);
return include $file;
@@ -471,6 +471,9 @@ protected static function _configureSession() {
if (!empty($sessionConfig['handler'])) {
$sessionConfig['ini']['session.save_handler'] = 'user';
}
+ if (!isset($sessionConfig['ini']['session.gc_maxlifetime'])) {
+ $sessionConfig['ini']['session.gc_maxlifetime'] = $sessionConfig['timeout'] * 60;
+ }
if (empty($_SESSION)) {
if (!empty($sessionConfig['ini']) && is_array($sessionConfig['ini'])) {
@@ -618,7 +618,7 @@ public function method() {
/**
* Get the host that the request was handled on.
*
- * @return void
+ * @return string
*/
public function host() {
return env('HTTP_HOST');
@@ -402,7 +402,6 @@ public function testExtractModelValidationInPlugin() {
$this->assertNotRegExp($pattern, $result);
}
-
/**
* Test that the extract shell overwrites existing files with the overwrite parameter
*
@@ -315,7 +315,7 @@ public function testInteractiveFieldValidation() {
$this->Task->initValidations();
$this->Task->interactive = true;
$this->Task->expects($this->any())->method('in')
- ->will($this->onConsecutiveCalls('21', 'y', '17', 'n'));
+ ->will($this->onConsecutiveCalls('22', 'y', '17', 'n'));
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
$expected = array('notempty' => 'notempty', 'maxlength' => 'maxlength');
@@ -333,7 +333,7 @@ public function testInteractiveFieldValidationWithBogusResponse() {
$this->Task->interactive = true;
$this->Task->expects($this->any())->method('in')
- ->will($this->onConsecutiveCalls('999999', '21', 'n'));
+ ->will($this->onConsecutiveCalls('999999', '22', 'n'));
$this->Task->expects($this->at(7))->method('out')
->with($this->stringContains('make a valid'));
@@ -55,15 +55,6 @@ public function setUp() {
$this->response = $this->getMock('Cake\Network\Response');
}
-/**
- * tearDown
- *
- * @return void
- */
- public function tearDown() {
- parent::tearDown();
- }
-
/**
* test applying settings in the constructor
*
@@ -737,6 +737,8 @@ public function testCookieTimeoutFallback() {
TestCakeSession::start();
$this->assertEquals(400, Configure::read('Session.cookieTimeout'));
$this->assertEquals(400, Configure::read('Session.timeout'));
+ $this->assertEquals(400 * 60, ini_get('session.cookie_lifetime'));
+ $this->assertEquals(400 * 60, ini_get('session.gc_maxlifetime'));
$_SESSION = null;
Configure::write('Session', array(
@@ -241,7 +241,7 @@ public function testCacheClearOnSave() {
$data = array(
'OverallFavorite' => array(
'id' => 22,
- 'model_type' => '8-track',
+ 'model_type' => '8-track',
'model_id' => '3',
'priority' => '1'
)
@@ -26,15 +26,6 @@
*/
class CakeValidationSetTest extends CakeTestCase {
-/**
- * setUp method
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- }
-
/**
* testValidate method
*
@@ -1617,6 +1617,20 @@ public function testClassicExtract() {
$this->assertEquals($expected, $result);
}
+/**
+ * test classicExtract with keys that exceed 32bit max int.
+ *
+ * @return void
+ */
+ public function testClassicExtractMaxInt() {
+ $data = array(
+ 'Data' => array(
+ '13376924712' => 'abc'
+ )
+ );
+ $this->assertEquals('abc', Set::classicExtract($data, 'Data.13376924712'));
+ }
+
/**
* testInsert method
*
@@ -1963,6 +1963,27 @@ public function testNumeric() {
$this->assertTrue(Validation::numeric('2.2'));
}
+/**
+ * testNaturalNumber method
+ *
+ * @return void
+ */
+ public function testNaturalNumber() {
+ $this->assertFalse(Validation::naturalNumber('teststring'));
+ $this->assertFalse(Validation::naturalNumber('5.4'));
+ $this->assertFalse(Validation::naturalNumber(99.004));
+ $this->assertFalse(Validation::naturalNumber('0,05'));
+ $this->assertFalse(Validation::naturalNumber('-2'));
+ $this->assertFalse(Validation::naturalNumber(-2));
+ $this->assertFalse(Validation::naturalNumber('0'));
+ $this->assertFalse(Validation::naturalNumber('050'));
+
+ $this->assertTrue(Validation::naturalNumber('2'));
+ $this->assertTrue(Validation::naturalNumber(49));
+ $this->assertTrue(Validation::naturalNumber('0', true));
+ $this->assertTrue(Validation::naturalNumber(0, true));
+ }
+
/**
* testPhone method
*
View
@@ -562,8 +562,8 @@ public static function classicExtract($data, $path = null) {
foreach ($path as $i => $key) {
if (is_numeric($key) && intval($key) > 0 || $key === '0') {
- if (isset($data[intval($key)])) {
- $data = $data[intval($key)];
+ if (isset($data[$key])) {
+ $data = $data[$key];
} else {
return null;
}
@@ -564,6 +564,19 @@ public static function numeric($check) {
return is_numeric($check);
}
+/**
+ * Checks if a value is a natural number.
+ *
+ * @param string $check Value to check
+ * @param boolean $allowZero Set true to allow zero, defaults to false
+ * @return boolean Success
+ * @see http://en.wikipedia.org/wiki/Natural_number
+ */
+ public static function naturalNumber($check, $allowZero = false) {
+ $regex = $allowZero ? '/^(?:0|[1-9][0-9]*)$/' : '/^[1-9][0-9]*$/';
+ return self::_check($check, $regex);
+ }
+
/**
* Check that a value is a valid phone number.
*

0 comments on commit cdadaee

Please sign in to comment.