Skip to content
Browse files

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

  • Loading branch information...
2 parents 57a76bf + 1c0f97e commit cdadaeebb7afbad8cacb6d6c9796b935fc4199a2 @jrbasso committed
View
4 lib/Cake/Core/App.php
@@ -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;
View
3 lib/Cake/Model/Datasource/Session.php
@@ -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'])) {
View
2 lib/Cake/Network/Request.php
@@ -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');
View
1 lib/Cake/Test/TestCase/Console/Command/Task/ExtractTaskTest.php
@@ -402,7 +402,6 @@ public function testExtractModelValidationInPlugin() {
$this->assertNotRegExp($pattern, $result);
}
-
/**
* Test that the extract shell overwrites existing files with the overwrite parameter
*
View
4 lib/Cake/Test/TestCase/Console/Command/Task/ModelTaskTest.php
@@ -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'));
View
9 lib/Cake/Test/TestCase/Controller/Component/Auth/BasicAuthenticateTest.php
@@ -56,15 +56,6 @@ public function setUp() {
}
/**
- * tearDown
- *
- * @return void
- */
- public function tearDown() {
- parent::tearDown();
- }
-
-/**
* test applying settings in the constructor
*
* @return void
View
2 lib/Cake/Test/TestCase/Model/Datasource/CakeSessionTest.php
@@ -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(
View
2 lib/Cake/Test/TestCase/Model/ModelWriteTest.php
@@ -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'
)
View
9 lib/Cake/Test/TestCase/Model/Validator/CakeValidationSetTest.php
@@ -27,15 +27,6 @@
class CakeValidationSetTest extends CakeTestCase {
/**
- * setUp method
- *
- * @return void
- */
- public function setUp() {
- parent::setUp();
- }
-
-/**
* testValidate method
*
* @return void
View
14 lib/Cake/Test/TestCase/Utility/SetTest.php
@@ -1618,6 +1618,20 @@ public function testClassicExtract() {
}
/**
+ * 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
*
* @see Hash tests, as Set::insert() is just a proxy.
View
21 lib/Cake/Test/TestCase/Utility/ValidationTest.php
@@ -1964,6 +1964,27 @@ public function testNumeric() {
}
/**
+ * 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
*
* @return void
View
4 lib/Cake/Utility/Set.php
@@ -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;
}
View
13 lib/Cake/Utility/Validation.php
@@ -565,6 +565,19 @@ public static function 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.
*
* @param string|array $check Value to check (string or array)

0 comments on commit cdadaee

Please sign in to comment.
Something went wrong with that request. Please try again.