|
|
@@ -536,6 +536,7 @@ class FormHelperTest extends CakeTestCase {
|
|
|
parent::setUp();
|
|
|
|
|
|
Configure::write('App.base', '');
|
|
|
+ Configure::delete('Asset');
|
|
|
$this->Controller = new ContactTestController();
|
|
|
$this->View = new View($this->Controller);
|
|
|
|
|
|
@@ -1455,22 +1456,39 @@ class FormHelperTest extends CakeTestCase {
|
|
|
*/
|
|
|
public function testTagIsInvalid() {
|
|
|
$Contact = ClassRegistry::getObject('Contact');
|
|
|
- $Contact->validationErrors[0]['email'] = array('Please provide an email');
|
|
|
+ $Contact->validationErrors[0]['email'] = $expected = array('Please provide an email');
|
|
|
|
|
|
$this->Form->setEntity('Contact.0.email');
|
|
|
$result = $this->Form->tagIsInvalid();
|
|
|
- $expected = array('Please provide an email');
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
|
|
$this->Form->setEntity('Contact.1.email');
|
|
|
$result = $this->Form->tagIsInvalid();
|
|
|
- $expected = false;
|
|
|
- $this->assertSame($expected, $result);
|
|
|
+ $this->assertFalse($result);
|
|
|
|
|
|
$this->Form->setEntity('Contact.0.name');
|
|
|
$result = $this->Form->tagIsInvalid();
|
|
|
- $expected = false;
|
|
|
- $this->assertSame($expected, $result);
|
|
|
+ $this->assertFalse($result);
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test tagIsInvalid with validation errors from a saveMany
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testTagIsInvalidSaveMany() {
|
|
|
+ $Contact = ClassRegistry::getObject('Contact');
|
|
|
+ $Contact->validationErrors[0]['email'] = $expected = array('Please provide an email');
|
|
|
+
|
|
|
+ $this->Form->create('Contact');
|
|
|
+
|
|
|
+ $this->Form->setEntity('0.email');
|
|
|
+ $result = $this->Form->tagIsInvalid();
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
+
|
|
|
+ $this->Form->setEntity('0.Contact.email');
|
|
|
+ $result = $this->Form->tagIsInvalid();
|
|
|
+ $this->assertEquals($expected, $result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -8534,6 +8552,24 @@ class FormHelperTest extends CakeTestCase {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * test the correct display of multi-record form validation errors.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testSaveManyRecordFormValidationErrors() {
|
|
|
+ $this->Form->create('ValidateUser');
|
|
|
+ $ValidateUser = ClassRegistry::getObject('ValidateUser');
|
|
|
+ $ValidateUser->validationErrors[0]['ValidateItem']['name'] = array('Error in field name');
|
|
|
+
|
|
|
+ $result = $this->Form->error('0.ValidateUser.ValidateItem.name');
|
|
|
+ $this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field name', '/div'));
|
|
|
+
|
|
|
+ $ValidateUser->validationErrors[0]['city'] = array('Error in field city');
|
|
|
+ $result = $this->Form->error('ValidateUser.0.city');
|
|
|
+ $this->assertTags($result, array('div' => array('class' => 'error-message'), 'Error in field city', '/div'));
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* tests the ability to change the order of the form input placeholder "input", "label", "before", "between", "after", "error"
|
|
|
*
|
|
|
* @return void
|