Merge branch 'master' into 2.4

This commit is contained in:
ADmad 2013-04-27 18:39:30 +05:30
commit 8135d405a3
8 changed files with 66 additions and 8 deletions

View file

@ -369,6 +369,7 @@ class FileEngine extends CacheEngine {
unlink($object->getPathName());
}
}
$this->_File = null;
return true;
}
}

View file

@ -74,7 +74,8 @@ class CakeResponse {
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Time-out'
504 => 'Gateway Time-out',
505 => 'Unsupported Version'
);
/**

View file

@ -1093,7 +1093,8 @@ class Router {
* @return CakeRoute Matching route object.
*/
public static function currentRoute() {
return self::$_currentRoute[count(self::$_currentRoute) - 1];
$count = count(self::$_currentRoute) - 1;
return ($count >= 0) ? self::$_currentRoute[$count] : false;
}
/**

View file

@ -411,6 +411,32 @@ class FileEngineTest extends CakeTestCase {
$this->assertTrue(Cache::write('test_groups3', 'value3', 'file_groups'));
}
/**
* Test that clearing with repeat writes works properly
*/
public function testClearingWithRepeatWrites() {
Cache::config('repeat', array(
'engine' => 'File', 'groups' => array('users')
));
$this->assertTrue(Cache::write('user', 'rchavik', 'repeat'));
$this->assertEquals('rchavik', Cache::read('user', 'repeat'));
Cache::delete('user', 'repeat');
$this->assertEquals(false, Cache::read('user', 'repeat'));
$this->assertTrue(Cache::write('user', 'ADmad', 'repeat'));
$this->assertEquals('ADmad', Cache::read('user', 'repeat'));
Cache::clearGroup('users', 'repeat');
$this->assertEquals(false, Cache::read('user', 'repeat'));
$this->assertTrue(Cache::write('user', 'markstory', 'repeat'));
$this->assertEquals('markstory', Cache::read('user', 'repeat'));
Cache::drop('repeat');
}
/**
* Tests that deleting from a groups-enabled config is possible
*

View file

@ -361,7 +361,7 @@ class CakeResponseTest extends CakeTestCase {
public function testHttpCodes() {
$response = new CakeResponse();
$result = $response->httpCodes();
$this->assertEquals(39, count($result));
$this->assertEquals(40, count($result));
$result = $response->httpCodes(100);
$expected = array(100 => 'Continue');
@ -374,7 +374,7 @@ class CakeResponseTest extends CakeTestCase {
$result = $response->httpCodes($codes);
$this->assertTrue($result);
$this->assertEquals(41, count($response->httpCodes()));
$this->assertEquals(42, count($response->httpCodes()));
$result = $response->httpCodes(1337);
$expected = array(1337 => 'Undefined Unicorn');
@ -383,7 +383,7 @@ class CakeResponseTest extends CakeTestCase {
$codes = array(404 => 'Sorry Bro');
$result = $response->httpCodes($codes);
$this->assertTrue($result);
$this->assertEquals(41, count($response->httpCodes()));
$this->assertEquals(42, count($response->httpCodes()));
$result = $response->httpCodes(404);
$expected = array(404 => 'Sorry Bro');

View file

@ -2161,6 +2161,16 @@ class RouterTest extends CakeTestCase {
$this->assertEquals(Router::stripPlugin($url, null), $url);
}
/**
* testCurrentRouteWhenNonExistentRoute
*
* @return void
*/
public function testCurrentRouteWhenNonExistentRoute() {
$route = Router::currentRoute();
$this->assertFalse($route);
}
/**
* testCurrentRoute
*

View file

@ -8697,7 +8697,7 @@ class FormHelperTest extends CakeTestCase {
$this->Form->inputDefaults(array('required' => false));
$result = $this->Form->input('Contact.imrequired');
$expected = array(
'div' => array('class' => 'input text required'),
'div' => array('class' => 'input text'),
'label' => array('for' => 'ContactImrequired'),
'Imrequired',
'/label',
@ -8711,6 +8711,23 @@ class FormHelperTest extends CakeTestCase {
$result = $this->Form->input('Contact.imrequired', array('required' => false));
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imrequired', array('required' => true));
$expected = array(
'div' => array('class' => 'input text required'),
'label' => array('for' => 'ContactImrequired'),
'Imrequired',
'/label',
'input' => array(
'required' => 'required', 'type' => 'text', 'name' => 'data[Contact][imrequired]',
'id' => 'ContactImrequired'
),
'/div'
);
$this->assertTags($result, $expected);
$result = $this->Form->input('Contact.imrequired', array('required' => null));
$this->assertTags($result, $expected);
}
/**

View file

@ -1271,8 +1271,10 @@ class FormHelper extends AppHelper {
} elseif (is_array($div)) {
$divOptions = array_merge($divOptions, $div);
}
if ($this->_introspectModel($this->model(), 'validates', $this->field())) {
if (
$this->_extractOption('required', $options) !== false &&
$this->_introspectModel($this->model(), 'validates', $this->field())
) {
$divOptions = $this->addClass($divOptions, 'required');
}
if (!isset($divOptions['tag'])) {