diff --git a/tests/TestCase/View/Helper/FormHelperTest.php b/tests/TestCase/View/Helper/FormHelperTest.php index adefa46a5ff..4397dc0b070 100755 --- a/tests/TestCase/View/Helper/FormHelperTest.php +++ b/tests/TestCase/View/Helper/FormHelperTest.php @@ -2069,97 +2069,38 @@ public function testFormValidationMultiRecord() { TableRegistry::get('Contacts', [ 'className' => __NAMESPACE__ . '\ContactsTable' ]); + $one->errors('email', ['invalid email']); $two->errors('name', ['This is wrong']); $this->Form->create([$one, $two], ['context' => ['table' => 'Contacts']]); - $result = $this->Form->input('Contacts.1.name'); - $expected = array( - 'div' => array('class' => 'input text error'), - 'label' => array('for' => 'contacts-1-name'), - 'Name', - '/label', - 'input' => array( - 'type' => 'text', 'name' => 'Contacts[1][name]', 'id' => 'contacts-1-name', - 'class' => 'form-error', 'maxlength' => 255 - ), - array('div' => array('class' => 'error-message')), - 'This is wrong', - '/div', - '/div' - ); - $this->assertTags($result, $expected); - } -/** - * testMultipleInputValidation method - * - * test multiple record form validation error display. - * - * @return void - */ - public function testMultipleInputValidation() { - $this->markTestIncomplete('Need to revisit once models work again.'); - $Address->validationErrors[0] = array( - 'title' => array('This field cannot be empty'), - 'first_name' => array('This field cannot be empty') - ); - $Address->validationErrors[1] = array( - 'last_name' => array('You must have a last name') - ); - $this->Form->create(); - - $result = $this->Form->input('Address.0.title'); + $result = $this->Form->input('Contacts.0.email'); $expected = array( - 'div' => array('class'), - 'label' => array('for'), - 'preg:/[^<]+/', + 'div' => array('class' => 'input email error'), + 'label' => array('for' => 'contacts-0-email'), + 'Email', '/label', 'input' => array( - 'type' => 'text', 'name', 'id', 'class' => 'form-error' + 'type' => 'text', 'name' => 'Contacts[0][email]', 'id' => 'contacts-0-email', + 'class' => 'form-error', 'maxlength' => 255 ), array('div' => array('class' => 'error-message')), - 'This field cannot be empty', + 'invalid email', '/div', '/div' ); - $this->assertTags($result, $expected); - $result = $this->Form->input('Address.0.first_name'); - $expected = array( - 'div' => array('class'), - 'label' => array('for'), - 'preg:/[^<]+/', - '/label', - 'input' => array('type' => 'text', 'name', 'id', 'class' => 'form-error'), - array('div' => array('class' => 'error-message')), - 'This field cannot be empty', - '/div', - '/div' - ); - $this->assertTags($result, $expected); - - $result = $this->Form->input('Address.0.last_name'); - $expected = array( - 'div' => array('class'), - 'label' => array('for'), - 'preg:/[^<]+/', - '/label', - 'input' => array('type' => 'text', 'name', 'id'), - '/div' - ); - $this->assertTags($result, $expected); - - $result = $this->Form->input('Address.1.last_name'); + $result = $this->Form->input('Contacts.1.name'); $expected = array( - 'div' => array('class'), - 'label' => array('for'), - 'preg:/[^<]+/', + 'div' => array('class' => 'input text error'), + 'label' => array('for' => 'contacts-1-name'), + 'Name', '/label', 'input' => array( - 'type' => 'text', 'name' => 'preg:/[^<]+/', - 'id' => 'preg:/[^<]+/', 'class' => 'form-error' + 'type' => 'text', 'name' => 'Contacts[1][name]', 'id' => 'contacts-1-name', + 'class' => 'form-error', 'maxlength' => 255 ), array('div' => array('class' => 'error-message')), - 'You must have a last name', + 'This is wrong', '/div', '/div' );