Merge branch '2.5' into 2.6

Conflicts:
	lib/Cake/VERSION.txt
This commit is contained in:
mark_story 2014-04-28 20:34:29 -04:00
commit 5432f834ff
3 changed files with 56 additions and 4 deletions

View file

@ -142,7 +142,7 @@ class SecurityComponentTest extends CakeTestCase {
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$request = $this->getMock('CakeRequest', ['here'], ['posts/index', false]); $request = $this->getMock('CakeRequest', array('here'), array('posts/index', false));
$request->addParams(array('controller' => 'posts', 'action' => 'index')); $request->addParams(array('controller' => 'posts', 'action' => 'index'));
$request->expects($this->any()) $request->expects($this->any())
->method('here') ->method('here')
@ -1067,7 +1067,7 @@ class SecurityComponentTest extends CakeTestCase {
* *
* @return void * @return void
*/ */
public function testRadio() { public function testValidatePostRadio() {
$this->Controller->Security->startup($this->Controller); $this->Controller->Security->startup($this->Controller);
$key = $this->Controller->request->params['_Token']['key']; $key = $this->Controller->request->params['_Token']['key'];
$fields = '3be63770e7953c6d2119f5377a9303372040f66f%3An%3A0%3A%7B%7D'; $fields = '3be63770e7953c6d2119f5377a9303372040f66f%3An%3A0%3A%7B%7D';
@ -1101,6 +1101,38 @@ class SecurityComponentTest extends CakeTestCase {
$this->assertTrue($result); $this->assertTrue($result);
} }
/**
* test validatePost uses here() as a hash input.
*
* @return void
*/
public function testValidatePostUrlAsHashInput() {
$this->Controller->Security->startup($this->Controller);
$key = $this->Controller->request->params['_Token']['key'];
$fields = '5415d31b4483c1e09ddb58d2a91ba9650b12aa83%3A';
$unlocked = '';
$this->Controller->request->data = array(
'Model' => array('username' => '', 'password' => ''),
'_Token' => compact('key', 'fields', 'unlocked')
);
$this->assertTrue($this->Controller->Security->validatePost($this->Controller));
$request = $this->getMock('CakeRequest', array('here'), array('articles/edit/1', false));
$request->expects($this->at(0))
->method('here')
->will($this->returnValue('/posts/index?page=1'));
$request->expects($this->at(1))
->method('here')
->will($this->returnValue('/posts/edit/1'));
$this->Controller->Security->request = $request;
$this->assertFalse($this->Controller->Security->validatePost($this->Controller));
$this->assertFalse($this->Controller->Security->validatePost($this->Controller));
}
/** /**
* test that a requestAction's controller will have the _Token appended to * test that a requestAction's controller will have the _Token appended to
* the params. * the params.

View file

@ -8478,6 +8478,26 @@ class FormHelperTest extends CakeTestCase {
$this->assertTags($result, $expected); $this->assertTags($result, $expected);
} }
/**
* test that create() works without raising errors with a Mock Model
*
* @return void
*/
public function testCreateNoErrorsWithMockModel() {
$encoding = strtolower(Configure::read('App.encoding'));
$ContactMock = $this->getMockBuilder('Contact')
->disableOriginalConstructor()
->getMock();
ClassRegistry::removeObject('Contact');
ClassRegistry::addObject('Contact', $ContactMock);
$result = $this->Form->create('Contact', array('type' => 'GET'));
$expected = array('form' => array(
'id' => 'ContactAddForm', 'method' => 'get', 'action' => '/contacts/add',
'accept-charset' => $encoding
));
$this->assertTags($result, $expected);
}
/** /**
* test creating a get form, and get form inputs. * test creating a get form, and get form inputs.
* *

View file

@ -234,7 +234,7 @@ class FormHelper extends AppHelper {
if ($key === 'validates' && !isset($this->fieldset[$model]['validates'])) { if ($key === 'validates' && !isset($this->fieldset[$model]['validates'])) {
$validates = array(); $validates = array();
foreach ($object->validator() as $validateField => $validateProperties) { foreach (iterator_to_array($object->validator(), true) as $validateField => $validateProperties) {
if ($this->_isRequiredField($validateProperties)) { if ($this->_isRequiredField($validateProperties)) {
$validates[$validateField] = true; $validates[$validateField] = true;
} }